Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: Icepique/iceShortUrlPlugin
base: master
...
head fork: CollectorsQuest/iceShortUrlPlugin
compare: master
Checking mergeability… Don’t worry, you can still create the pull request.
  • 1 commit
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
229 lib/model/om/BaseiceModelShortUrl.php
@@ -25,6 +25,12 @@
protected static $peer;
/**
+ * The flag var to prevent infinit loop in deep copy
+ * @var boolean
+ */
+ protected $startCopy = false;
+
+ /**
* The value for the id field.
* @var int
*/
@@ -101,6 +107,12 @@
protected $alreadyInValidation = false;
/**
+ * An array of objects scheduled for deletion.
+ * @var array
+ */
+ protected $iceModelShortUrlHitsScheduledForDeletion = null;
+
+ /**
* Applies default values to this object.
* This method should be called from the object's constructor (or
* equivalent initialization method).
@@ -711,7 +723,7 @@ public function delete(PropelPDO $con = null)
$con->commit();
}
}
- catch (PropelException $e)
+ catch (Exception $e)
{
$con->rollBack();
throw $e;
@@ -807,7 +819,7 @@ public function save(PropelPDO $con = null)
$con->commit();
return $affectedRows;
}
- catch (PropelException $e)
+ catch (Exception $e)
{
$con->rollBack();
throw $e;
@@ -832,33 +844,30 @@ protected function doSave(PropelPDO $con)
{
$this->alreadyInSave = true;
- if ($this->isNew() )
- {
- $this->modifiedColumns[] = iceModelShortUrlPeer::ID;
- }
-
- // If this object has been modified, then save it to the database.
- if ($this->isModified())
+ if ($this->isNew() || $this->isModified())
{
+ // persist changes
if ($this->isNew())
{
- $criteria = $this->buildCriteria();
- if ($criteria->keyContainsValue(iceModelShortUrlPeer::ID) )
- {
- throw new PropelException('Cannot insert a value for auto-increment primary key ('.iceModelShortUrlPeer::ID.')');
- }
-
- $pk = BasePeer::doInsert($criteria, $con);
- $affectedRows = 1;
- $this->setId($pk); //[IMV] update autoincrement primary key
- $this->setNew(false);
+ $this->doInsert($con);
}
else
{
- $affectedRows = iceModelShortUrlPeer::doUpdate($this, $con);
+ $this->doUpdate($con);
}
+ $affectedRows += 1;
+ $this->resetModified();
+ }
- $this->resetModified(); // [HL] After being saved an object is no longer 'modified'
+ if ($this->iceModelShortUrlHitsScheduledForDeletion !== null)
+ {
+ if (!$this->iceModelShortUrlHitsScheduledForDeletion->isEmpty())
+ {
+ iceModelShortUrlHitQuery::create()
+ ->filterByPrimaryKeys($this->iceModelShortUrlHitsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->iceModelShortUrlHitsScheduledForDeletion = null;
+ }
}
if ($this->colliceModelShortUrlHits !== null)
@@ -879,6 +888,140 @@ protected function doSave(PropelPDO $con)
}
/**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = iceModelShortUrlPeer::ID;
+ if (null !== $this->id)
+ {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . iceModelShortUrlPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(iceModelShortUrlPeer::ID))
+ {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(iceModelShortUrlPeer::URL))
+ {
+ $modifiedColumns[':p' . $index++] = '`URL`';
+ }
+ if ($this->isColumnModified(iceModelShortUrlPeer::URL_DECODED))
+ {
+ $modifiedColumns[':p' . $index++] = '`URL_DECODED`';
+ }
+ if ($this->isColumnModified(iceModelShortUrlPeer::HASH))
+ {
+ $modifiedColumns[':p' . $index++] = '`HASH`';
+ }
+ if ($this->isColumnModified(iceModelShortUrlPeer::VIEW_COUNT))
+ {
+ $modifiedColumns[':p' . $index++] = '`VIEW_COUNT`';
+ }
+ if ($this->isColumnModified(iceModelShortUrlPeer::IS_PUBLIC))
+ {
+ $modifiedColumns[':p' . $index++] = '`IS_PUBLIC`';
+ }
+ if ($this->isColumnModified(iceModelShortUrlPeer::IS_ENABLED))
+ {
+ $modifiedColumns[':p' . $index++] = '`IS_ENABLED`';
+ }
+ if ($this->isColumnModified(iceModelShortUrlPeer::CREATED_AT))
+ {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(iceModelShortUrlPeer::UPDATED_AT))
+ {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `short_url` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try
+ {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName)
+ {
+ switch ($columnName)
+ {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`URL`':
+ $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR);
+ break;
+ case '`URL_DECODED`':
+ $stmt->bindValue($identifier, $this->url_decoded, PDO::PARAM_STR);
+ break;
+ case '`HASH`':
+ $stmt->bindValue($identifier, $this->hash, PDO::PARAM_STR);
+ break;
+ case '`VIEW_COUNT`':
+ $stmt->bindValue($identifier, $this->view_count, PDO::PARAM_INT);
+ break;
+ case '`IS_PUBLIC`':
+ $stmt->bindValue($identifier, (int) $this->is_public, PDO::PARAM_INT);
+ break;
+ case '`IS_ENABLED`':
+ $stmt->bindValue($identifier, (int) $this->is_enabled, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ }
+ catch (Exception $e)
+ {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try
+ {
+ $pk = $con->lastInsertId();
+ }
+ catch (Exception $e)
+ {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
* Array of ValidationFailed objects.
* @var array ValidationFailed[]
*/
@@ -1249,11 +1392,13 @@ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
- if ($deepCopy)
+ if ($deepCopy && !$this->startCopy)
{
// important: temporarily setNew(false) because this affects the behavior of
// the getter/setter methods for fkey referrer objects.
$copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
foreach ($this->geticeModelShortUrlHits() as $relObj)
{
@@ -1262,6 +1407,8 @@ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
}
}
+ //unflag object copy
+ $this->startCopy = false;
}
if ($makeNew)
@@ -1402,6 +1549,32 @@ public function geticeModelShortUrlHits($criteria = null, PropelPDO $con = null)
}
/**
+ * Sets a collection of iceModelShortUrlHit objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $iceModelShortUrlHits A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ */
+ public function seticeModelShortUrlHits(PropelCollection $iceModelShortUrlHits, PropelPDO $con = null)
+ {
+ $this->iceModelShortUrlHitsScheduledForDeletion = $this->geticeModelShortUrlHits(new Criteria(), $con)->diff($iceModelShortUrlHits, false);
+
+ foreach ($iceModelShortUrlHits as $iceModelShortUrlHit)
+ {
+ // Fix issue with collection modified by reference
+ if ($iceModelShortUrlHit->isNew())
+ {
+ $iceModelShortUrlHit->seticeModelShortUrl($this);
+ }
+ $this->addiceModelShortUrlHit($iceModelShortUrlHit);
+ }
+
+ $this->colliceModelShortUrlHits = $iceModelShortUrlHits;
+ }
+
+ /**
* Returns the number of related iceModelShortUrlHit objects.
*
* @param Criteria $criteria
@@ -1450,14 +1623,22 @@ public function addiceModelShortUrlHit(iceModelShortUrlHit $l)
$this->initiceModelShortUrlHits();
}
if (!$this->colliceModelShortUrlHits->contains($l)) { // only add it if the **same** object is not already associated
- $this->colliceModelShortUrlHits[]= $l;
- $l->seticeModelShortUrl($this);
+ $this->doAddiceModelShortUrlHit($l);
}
return $this;
}
/**
+ * @param iceModelShortUrlHit $iceModelShortUrlHit The iceModelShortUrlHit object to add.
+ */
+ protected function doAddiceModelShortUrlHit($iceModelShortUrlHit)
+ {
+ $this->colliceModelShortUrlHits[]= $iceModelShortUrlHit;
+ $iceModelShortUrlHit->seticeModelShortUrl($this);
+ }
+
+ /**
* Clears the current object and sets all attributes to their default values
*/
public function clear()
View
176 lib/model/om/BaseiceModelShortUrlHit.php
@@ -25,6 +25,12 @@
protected static $peer;
/**
+ * The flag var to prevent infinit loop in deep copy
+ * @var boolean
+ */
+ protected $startCopy = false;
+
+ /**
* The value for the id field.
* @var int
*/
@@ -655,7 +661,7 @@ public function delete(PropelPDO $con = null)
$con->commit();
}
}
- catch (PropelException $e)
+ catch (Exception $e)
{
$con->rollBack();
throw $e;
@@ -751,7 +757,7 @@ public function save(PropelPDO $con = null)
$con->commit();
return $affectedRows;
}
- catch (PropelException $e)
+ catch (Exception $e)
{
$con->rollBack();
throw $e;
@@ -790,33 +796,19 @@ protected function doSave(PropelPDO $con)
$this->seticeModelShortUrl($this->aiceModelShortUrl);
}
- if ($this->isNew() )
- {
- $this->modifiedColumns[] = iceModelShortUrlHitPeer::ID;
- }
-
- // If this object has been modified, then save it to the database.
- if ($this->isModified())
+ if ($this->isNew() || $this->isModified())
{
+ // persist changes
if ($this->isNew())
{
- $criteria = $this->buildCriteria();
- if ($criteria->keyContainsValue(iceModelShortUrlHitPeer::ID) )
- {
- throw new PropelException('Cannot insert a value for auto-increment primary key ('.iceModelShortUrlHitPeer::ID.')');
- }
-
- $pk = BasePeer::doInsert($criteria, $con);
- $affectedRows += 1;
- $this->setId($pk); //[IMV] update autoincrement primary key
- $this->setNew(false);
+ $this->doInsert($con);
}
else
{
- $affectedRows += iceModelShortUrlHitPeer::doUpdate($this, $con);
+ $this->doUpdate($con);
}
-
- $this->resetModified(); // [HL] After being saved an object is no longer 'modified'
+ $affectedRows += 1;
+ $this->resetModified();
}
$this->alreadyInSave = false;
@@ -826,6 +818,133 @@ protected function doSave(PropelPDO $con)
}
/**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = iceModelShortUrlHitPeer::ID;
+ if (null !== $this->id)
+ {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . iceModelShortUrlHitPeer::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(iceModelShortUrlHitPeer::ID))
+ {
+ $modifiedColumns[':p' . $index++] = '`ID`';
+ }
+ if ($this->isColumnModified(iceModelShortUrlHitPeer::SHORT_URL_ID))
+ {
+ $modifiedColumns[':p' . $index++] = '`SHORT_URL_ID`';
+ }
+ if ($this->isColumnModified(iceModelShortUrlHitPeer::SESSION_ID))
+ {
+ $modifiedColumns[':p' . $index++] = '`SESSION_ID`';
+ }
+ if ($this->isColumnModified(iceModelShortUrlHitPeer::IP_ADDRESS))
+ {
+ $modifiedColumns[':p' . $index++] = '`IP_ADDRESS`';
+ }
+ if ($this->isColumnModified(iceModelShortUrlHitPeer::REFERRER))
+ {
+ $modifiedColumns[':p' . $index++] = '`REFERRER`';
+ }
+ if ($this->isColumnModified(iceModelShortUrlHitPeer::IS_MOBILE))
+ {
+ $modifiedColumns[':p' . $index++] = '`IS_MOBILE`';
+ }
+ if ($this->isColumnModified(iceModelShortUrlHitPeer::CREATED_AT))
+ {
+ $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
+ }
+ if ($this->isColumnModified(iceModelShortUrlHitPeer::UPDATED_AT))
+ {
+ $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `short_url_hit` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try
+ {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName)
+ {
+ switch ($columnName)
+ {
+ case '`ID`':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case '`SHORT_URL_ID`':
+ $stmt->bindValue($identifier, $this->short_url_id, PDO::PARAM_INT);
+ break;
+ case '`SESSION_ID`':
+ $stmt->bindValue($identifier, $this->session_id, PDO::PARAM_STR);
+ break;
+ case '`IP_ADDRESS`':
+ $stmt->bindValue($identifier, $this->ip_address, PDO::PARAM_STR);
+ break;
+ case '`REFERRER`':
+ $stmt->bindValue($identifier, $this->referrer, PDO::PARAM_STR);
+ break;
+ case '`IS_MOBILE`':
+ $stmt->bindValue($identifier, (int) $this->is_mobile, PDO::PARAM_INT);
+ break;
+ case '`CREATED_AT`':
+ $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
+ break;
+ case '`UPDATED_AT`':
+ $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ }
+ catch (Exception $e)
+ {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ try
+ {
+ $pk = $con->lastInsertId();
+ }
+ catch (Exception $e)
+ {
+ throw new PropelException('Unable to get autoincrement id.', $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
* Array of ValidationFailed objects.
* @var array ValidationFailed[]
*/
@@ -1188,6 +1307,19 @@ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
$copyObj->setIsMobile($this->getIsMobile());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy && !$this->startCopy)
+ {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ }
+
if ($makeNew)
{
$copyObj->setNew(true);
View
24 lib/model/om/BaseiceModelShortUrlHitPeer.php
@@ -20,9 +20,6 @@
/** the related Propel class for this table */
const OM_CLASS = 'iceModelShortUrlHit';
- /** A class that can be returned by this peer. */
- const CLASS_DEFAULT = 'plugins.iceShortUrlPlugin.lib.model.iceModelShortUrlHit';
-
/** the related TableMap class for this table */
const TM_CLASS = 'iceModelShortUrlHitTableMap';
@@ -464,7 +461,7 @@ public static function populateObjects(PDOStatement $stmt)
$results = array();
// set the class once to avoid overhead in the loop
- $cls = iceModelShortUrlHitPeer::getOMClass(false);
+ $cls = iceModelShortUrlHitPeer::getOMClass();
// populate the object(s)
while ($row = $stmt->fetch(PDO::FETCH_NUM))
{
@@ -625,7 +622,7 @@ public static function doSelectJoiniceModelShortUrl(Criteria $criteria, $con = n
else
{
- $cls = iceModelShortUrlHitPeer::getOMClass(false);
+ $cls = iceModelShortUrlHitPeer::getOMClass();
$obj1 = new $cls();
$obj1->hydrate($row);
@@ -639,7 +636,7 @@ public static function doSelectJoiniceModelShortUrl(Criteria $criteria, $con = n
if (!$obj2)
{
- $cls = iceModelShortUrlPeer::getOMClass(false);
+ $cls = iceModelShortUrlPeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol);
@@ -767,7 +764,7 @@ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_be
}
else
{
- $cls = iceModelShortUrlHitPeer::getOMClass(false);
+ $cls = iceModelShortUrlHitPeer::getOMClass();
$obj1 = new $cls();
$obj1->hydrate($row);
@@ -783,7 +780,7 @@ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_be
if (!$obj2)
{
- $cls = iceModelShortUrlPeer::getOMClass(false);
+ $cls = iceModelShortUrlPeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol2);
@@ -827,17 +824,12 @@ public static function buildTableMap()
/**
* The class that the Peer will make instances of.
*
- * If $withPrefix is true, the returned path
- * uses a dot-path notation which is tranalted into a path
- * relative to a location on the PHP include_path.
- * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
- * @param boolean $withPrefix Whether or not to return the path with the class name
- * @return string path.to.ClassName
+ * @return string ClassName
*/
- public static function getOMClass($withPrefix = true)
+ public static function getOMClass()
{
- return $withPrefix ? iceModelShortUrlHitPeer::CLASS_DEFAULT : iceModelShortUrlHitPeer::OM_CLASS;
+ return iceModelShortUrlHitPeer::OM_CLASS;
}
/**
View
923 lib/model/om/BaseiceModelShortUrlHitQuery.php
@@ -57,462 +57,579 @@
*/
abstract class BaseiceModelShortUrlHitQuery extends ModelCriteria
{
-
- /**
- * Initializes internal state of BaseiceModelShortUrlHitQuery object.
- *
- * @param string $dbName The dabase name
- * @param string $modelName The phpName of a model, e.g. 'Book'
- * @param string $modelAlias The alias for the model in this query, e.g. 'b'
- */
- public function __construct($dbName = 'propel', $modelName = 'iceModelShortUrlHit', $modelAlias = null)
+
+ /**
+ * Initializes internal state of BaseiceModelShortUrlHitQuery object.
+ *
+ * @param string $dbName The dabase name
+ * @param string $modelName The phpName of a model, e.g. 'Book'
+ * @param string $modelAlias The alias for the model in this query, e.g. 'b'
+ */
+ public function __construct($dbName = 'propel', $modelName = 'iceModelShortUrlHit', $modelAlias = null)
+ {
+ parent::__construct($dbName, $modelName, $modelAlias);
+ }
+
+ /**
+ * Returns a new iceModelShortUrlHitQuery object.
+ *
+ * @param string $modelAlias The alias of a model in the query
+ * @param Criteria $criteria Optional Criteria to build the query from
+ *
+ * @return iceModelShortUrlHitQuery
+ */
+ public static function create($modelAlias = null, $criteria = null)
+ {
+ if ($criteria instanceof iceModelShortUrlHitQuery)
{
- parent::__construct($dbName, $modelName, $modelAlias);
+ return $criteria;
}
-
- /**
- * Returns a new iceModelShortUrlHitQuery object.
- *
- * @param string $modelAlias The alias of a model in the query
- * @param Criteria $criteria Optional Criteria to build the query from
- *
- * @return iceModelShortUrlHitQuery
- */
- public static function create($modelAlias = null, $criteria = null)
+ $query = new iceModelShortUrlHitQuery();
+ if (null !== $modelAlias)
{
- if ($criteria instanceof iceModelShortUrlHitQuery) {
- return $criteria;
- }
- $query = new iceModelShortUrlHitQuery();
- if (null !== $modelAlias) {
- $query->setModelAlias($modelAlias);
- }
- if ($criteria instanceof Criteria) {
- $query->mergeWith($criteria);
- }
- return $query;
+ $query->setModelAlias($modelAlias);
}
-
- /**
- * Find object by primary key
- * Use instance pooling to avoid a database query if the object exists
- * <code>
- * $obj = $c->findPk(12, $con);
- * </code>
- * @param mixed $key Primary key to use for the query
- * @param PropelPDO $con an optional connection object
- *
- * @return iceModelShortUrlHit|array|mixed the result, formatted by the current formatter
- */
- public function findPk($key, $con = null)
+ if ($criteria instanceof Criteria)
{
- if ((null !== ($obj = iceModelShortUrlHitPeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) {
- // the object is alredy in the instance pool
- return $obj;
- } else {
- // the object has not been requested yet, or the formatter is not an object formatter
- $criteria = $this->isKeepQuery() ? clone $this : $this;
- $stmt = $criteria
- ->filterByPrimaryKey($key)
- ->getSelectStatement($con);
- return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
- }
+ $query->mergeWith($criteria);
}
+ return $query;
+ }
- /**
- * Find objects by primary key
- * <code>
- * $objs = $c->findPks(array(12, 56, 832), $con);
- * </code>
- * @param array $keys Primary keys to use for the query
- * @param PropelPDO $con an optional connection object
- *
- * @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
- */
- public function findPks($keys, $con = null)
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ * <code>
+ * $obj = $c->findPk(12, $con);
+ * </code>
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return iceModelShortUrlHit|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null)
{
- $criteria = $this->isKeepQuery() ? clone $this : $this;
- return $this
- ->filterByPrimaryKeys($keys)
- ->find($con);
+ return null;
}
-
- /**
- * Filter the query by primary key
- *
- * @param mixed $key Primary key to use for the query
- *
- * @return iceModelShortUrlHitQuery The current query, for fluid interface
- */
- public function filterByPrimaryKey($key)
+ if ((null !== ($obj = iceModelShortUrlHitPeer::getInstanceFromPool((string) $key))) && !$this->formatter)
{
- return $this->addUsingAlias(iceModelShortUrlHitPeer::ID, $key, Criteria::EQUAL);
+ // the object is alredy in the instance pool
+ return $obj;
}
-
- /**
- * Filter the query by a list of primary keys
- *
- * @param array $keys The list of primary key to use for the query
- *
- * @return iceModelShortUrlHitQuery The current query, for fluid interface
- */
- public function filterByPrimaryKeys($keys)
+ if ($con === null)
+ {
+ $con = Propel::getConnection(iceModelShortUrlHitPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ }
+ else
{
- return $this->addUsingAlias(iceModelShortUrlHitPeer::ID, $keys, Criteria::IN);
+ return $this->findPkSimple($key, $con);
}
+ }
- /**
- * Filter the query on the id column
- *
- * Example usage:
- * <code>
- * $query->filterById(1234); // WHERE id = 1234
- * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
- * $query->filterById(array('min' => 12)); // WHERE id > 12
- * </code>
- *
- * @param mixed $id The value to use as filter.
- * Use scalar values for equality.
- * Use array values for in_array() equivalent.
- * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return iceModelShortUrlHitQuery The current query, for fluid interface
- */
- public function filterById($id = null, $comparison = null)
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return iceModelShortUrlHit A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `SHORT_URL_ID`, `SESSION_ID`, `IP_ADDRESS`, `REFERRER`, `IS_MOBILE`, `CREATED_AT`, `UPDATED_AT` FROM `short_url_hit` WHERE `ID` = :p0';
+ try
{
- if (is_array($id) && null === $comparison) {
- $comparison = Criteria::IN;
- }
- return $this->addUsingAlias(iceModelShortUrlHitPeer::ID, $id, $comparison);
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
}
+ catch (Exception $e)
+ {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM))
+ {
+ $obj = new iceModelShortUrlHit();
+ $obj->hydrate($row);
+ iceModelShortUrlHitPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
- /**
- * Filter the query on the short_url_id column
- *
- * Example usage:
- * <code>
- * $query->filterByShortUrlId(1234); // WHERE short_url_id = 1234
- * $query->filterByShortUrlId(array(12, 34)); // WHERE short_url_id IN (12, 34)
- * $query->filterByShortUrlId(array('min' => 12)); // WHERE short_url_id > 12
- * </code>
- *
- * @see filterByiceModelShortUrl()
- *
- * @param mixed $shortUrlId The value to use as filter.
- * Use scalar values for equality.
- * Use array values for in_array() equivalent.
- * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return iceModelShortUrlHitQuery The current query, for fluid interface
- */
- public function filterByShortUrlId($shortUrlId = null, $comparison = null)
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return iceModelShortUrlHit|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ * <code>
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ * </code>
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null)
{
- if (is_array($shortUrlId)) {
- $useMinMax = false;
- if (isset($shortUrlId['min'])) {
- $this->addUsingAlias(iceModelShortUrlHitPeer::SHORT_URL_ID, $shortUrlId['min'], Criteria::GREATER_EQUAL);
- $useMinMax = true;
- }
- if (isset($shortUrlId['max'])) {
- $this->addUsingAlias(iceModelShortUrlHitPeer::SHORT_URL_ID, $shortUrlId['max'], Criteria::LESS_EQUAL);
- $useMinMax = true;
- }
- if ($useMinMax) {
- return $this;
- }
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
- }
- return $this->addUsingAlias(iceModelShortUrlHitPeer::SHORT_URL_ID, $shortUrlId, $comparison);
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
}
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
- /**
- * Filter the query on the session_id column
- *
- * Example usage:
- * <code>
- * $query->filterBySessionId('fooValue'); // WHERE session_id = 'fooValue'
- * $query->filterBySessionId('%fooValue%'); // WHERE session_id LIKE '%fooValue%'
- * </code>
- *
- * @param string $sessionId The value to use as filter.
- * Accepts wildcards (* and % trigger a LIKE)
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return iceModelShortUrlHitQuery The current query, for fluid interface
- */
- public function filterBySessionId($sessionId = null, $comparison = null)
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return iceModelShortUrlHitQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ return $this->addUsingAlias(iceModelShortUrlHitPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return iceModelShortUrlHitQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ return $this->addUsingAlias(iceModelShortUrlHitPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ * <code>
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ * </code>
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return iceModelShortUrlHitQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison)
{
- if (null === $comparison) {
- if (is_array($sessionId)) {
- $comparison = Criteria::IN;
- } elseif (preg_match('/[\%\*]/', $sessionId)) {
- $sessionId = str_replace('*', '%', $sessionId);
- $comparison = Criteria::LIKE;
- }
- }
- return $this->addUsingAlias(iceModelShortUrlHitPeer::SESSION_ID, $sessionId, $comparison);
+ $comparison = Criteria::IN;
}
+ return $this->addUsingAlias(iceModelShortUrlHitPeer::ID, $id, $comparison);
+ }
- /**
- * Filter the query on the ip_address column
- *
- * Example usage:
- * <code>
- * $query->filterByIpAddress('fooValue'); // WHERE ip_address = 'fooValue'
- * $query->filterByIpAddress('%fooValue%'); // WHERE ip_address LIKE '%fooValue%'
- * </code>
- *
- * @param string $ipAddress The value to use as filter.
- * Accepts wildcards (* and % trigger a LIKE)
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return iceModelShortUrlHitQuery The current query, for fluid interface
- */
- public function filterByIpAddress($ipAddress = null, $comparison = null)
+ /**
+ * Filter the query on the short_url_id column
+ *
+ * Example usage:
+ * <code>
+ * $query->filterByShortUrlId(1234); // WHERE short_url_id = 1234
+ * $query->filterByShortUrlId(array(12, 34)); // WHERE short_url_id IN (12, 34)
+ * $query->filterByShortUrlId(array('min' => 12)); // WHERE short_url_id > 12
+ * </code>
+ *
+ * @see filterByiceModelShortUrl()
+ *
+ * @param mixed $shortUrlId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return iceModelShortUrlHitQuery The current query, for fluid interface
+ */
+ public function filterByShortUrlId($shortUrlId = null, $comparison = null)
+ {
+ if (is_array($shortUrlId))
{
- if (null === $comparison) {
- if (is_array($ipAddress)) {
- $comparison = Criteria::IN;
- } elseif (preg_match('/[\%\*]/', $ipAddress)) {
- $ipAddress = str_replace('*', '%', $ipAddress);
- $comparison = Criteria::LIKE;
- }
- }
- return $this->addUsingAlias(iceModelShortUrlHitPeer::IP_ADDRESS, $ipAddress, $comparison);
+ $useMinMax = false;
+ if (isset($shortUrlId['min']))
+ {
+ $this->addUsingAlias(iceModelShortUrlHitPeer::SHORT_URL_ID, $shortUrlId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($shortUrlId['max']))
+ {
+ $this->addUsingAlias(iceModelShortUrlHitPeer::SHORT_URL_ID, $shortUrlId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax)
+ {
+ return $this;
+ }
+ if (null === $comparison)
+ {
+ $comparison = Criteria::IN;
+ }
}
+ return $this->addUsingAlias(iceModelShortUrlHitPeer::SHORT_URL_ID, $shortUrlId, $comparison);
+ }
- /**
- * Filter the query on the referrer column
- *
- * Example usage:
- * <code>
- * $query->filterByReferrer('fooValue'); // WHERE referrer = 'fooValue'
- * $query->filterByReferrer('%fooValue%'); // WHERE referrer LIKE '%fooValue%'
- * </code>
- *
- * @param string $referrer The value to use as filter.
- * Accepts wildcards (* and % trigger a LIKE)
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return iceModelShortUrlHitQuery The current query, for fluid interface
- */
- public function filterByReferrer($referrer = null, $comparison = null)
+ /**
+ * Filter the query on the session_id column
+ *
+ * Example usage:
+ * <code>
+ * $query->filterBySessionId('fooValue'); // WHERE session_id = 'fooValue'
+ * $query->filterBySessionId('%fooValue%'); // WHERE session_id LIKE '%fooValue%'
+ * </code>
+ *
+ * @param string $sessionId The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return iceModelShortUrlHitQuery The current query, for fluid interface
+ */
+ public function filterBySessionId($sessionId = null, $comparison = null)
+ {
+ if (null === $comparison)
{
- if (null === $comparison) {
- if (is_array($referrer)) {
- $comparison = Criteria::IN;
- } elseif (preg_match('/[\%\*]/', $referrer)) {
- $referrer = str_replace('*', '%', $referrer);
- $comparison = Criteria::LIKE;
- }
- }
- return $this->addUsingAlias(iceModelShortUrlHitPeer::REFERRER, $referrer, $comparison);
+ if (is_array($sessionId))
+ {
+ $comparison = Criteria::IN;
+ }
+ elseif (preg_match('/[\%\*]/', $sessionId))
+ {
+ $sessionId = str_replace('*', '%', $sessionId);
+ $comparison = Criteria::LIKE;
+ }
}
+ return $this->addUsingAlias(iceModelShortUrlHitPeer::SESSION_ID, $sessionId, $comparison);
+ }
- /**
- * Filter the query on the is_mobile column
- *
- * Example usage:
- * <code>
- * $query->filterByIsMobile(true); // WHERE is_mobile = true
- * $query->filterByIsMobile('yes'); // WHERE is_mobile = true
- * </code>
- *
- * @param boolean|string $isMobile The value to use as filter.
- * Non-boolean arguments are converted using the following rules:
- * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
- * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
- * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return iceModelShortUrlHitQuery The current query, for fluid interface
- */
- public function filterByIsMobile($isMobile = null, $comparison = null)
+ /**
+ * Filter the query on the ip_address column
+ *
+ * Example usage:
+ * <code>
+ * $query->filterByIpAddress('fooValue'); // WHERE ip_address = 'fooValue'
+ * $query->filterByIpAddress('%fooValue%'); // WHERE ip_address LIKE '%fooValue%'
+ * </code>
+ *
+ * @param string $ipAddress The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return iceModelShortUrlHitQuery The current query, for fluid interface
+ */
+ public function filterByIpAddress($ipAddress = null, $comparison = null)
+ {
+ if (null === $comparison)
{
- if (is_string($isMobile)) {
- $is_mobile = in_array(strtolower($isMobile), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
- }
- return $this->addUsingAlias(iceModelShortUrlHitPeer::IS_MOBILE, $isMobile, $comparison);
+ if (is_array($ipAddress))
+ {
+ $comparison = Criteria::IN;
+ }
+ elseif (preg_match('/[\%\*]/', $ipAddress))
+ {
+ $ipAddress = str_replace('*', '%', $ipAddress);
+ $comparison = Criteria::LIKE;
+ }
}
+ return $this->addUsingAlias(iceModelShortUrlHitPeer::IP_ADDRESS, $ipAddress, $comparison);
+ }
- /**
- * Filter the query on the created_at column
- *
- * Example usage:
- * <code>
- * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
- * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
- * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
- * </code>
- *
- * @param mixed $createdAt The value to use as filter.
- * Values can be integers (unix timestamps), DateTime objects, or strings.
- * Empty strings are treated as NULL.
- * Use scalar values for equality.
- * Use array values for in_array() equivalent.
- * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return iceModelShortUrlHitQuery The current query, for fluid interface
- */
- public function filterByCreatedAt($createdAt = null, $comparison = null)
+ /**
+ * Filter the query on the referrer column
+ *
+ * Example usage:
+ * <code>
+ * $query->filterByReferrer('fooValue'); // WHERE referrer = 'fooValue'
+ * $query->filterByReferrer('%fooValue%'); // WHERE referrer LIKE '%fooValue%'
+ * </code>
+ *
+ * @param string $referrer The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return iceModelShortUrlHitQuery The current query, for fluid interface
+ */
+ public function filterByReferrer($referrer = null, $comparison = null)
+ {
+ if (null === $comparison)
{
- if (is_array($createdAt)) {
- $useMinMax = false;
- if (isset($createdAt['min'])) {
- $this->addUsingAlias(iceModelShortUrlHitPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
- $useMinMax = true;
- }
- if (isset($createdAt['max'])) {
- $this->addUsingAlias(iceModelShortUrlHitPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
- $useMinMax = true;
- }
- if ($useMinMax) {
- return $this;
- }
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
- }
- return $this->addUsingAlias(iceModelShortUrlHitPeer::CREATED_AT, $createdAt, $comparison);
+ if (is_array($referrer))
+ {
+ $comparison = Criteria::IN;
+ }
+ elseif (preg_match('/[\%\*]/', $referrer))
+ {
+ $referrer = str_replace('*', '%', $referrer);
+ $comparison = Criteria::LIKE;
+ }
}
+ return $this->addUsingAlias(iceModelShortUrlHitPeer::REFERRER, $referrer, $comparison);
+ }
- /**
- * Filter the query on the updated_at column
- *
- * Example usage:
- * <code>
- * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
- * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
- * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
- * </code>
- *
- * @param mixed $updatedAt The value to use as filter.
- * Values can be integers (unix timestamps), DateTime objects, or strings.
- * Empty strings are treated as NULL.
- * Use scalar values for equality.
- * Use array values for in_array() equivalent.
- * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return iceModelShortUrlHitQuery The current query, for fluid interface
- */
- public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ /**
+ * Filter the query on the is_mobile column
+ *
+ * Example usage:
+ * <code>
+ * $query->filterByIsMobile(true); // WHERE is_mobile = true
+ * $query->filterByIsMobile('yes'); // WHERE is_mobile = true
+ * </code>
+ *
+ * @param boolean|string $isMobile The value to use as filter.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return iceModelShortUrlHitQuery The current query, for fluid interface
+ */
+ public function filterByIsMobile($isMobile = null, $comparison = null)
+ {
+ if (is_string($isMobile))
{
- if (is_array($updatedAt)) {
- $useMinMax = false;
- if (isset($updatedAt['min'])) {
- $this->addUsingAlias(iceModelShortUrlHitPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
- $useMinMax = true;
- }
- if (isset($updatedAt['max'])) {
- $this->addUsingAlias(iceModelShortUrlHitPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
- $useMinMax = true;
- }
- if ($useMinMax) {
- return $this;
- }
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
- }
- return $this->addUsingAlias(iceModelShortUrlHitPeer::UPDATED_AT, $updatedAt, $comparison);
+ $is_mobile = in_array(strtolower($isMobile), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
+ return $this->addUsingAlias(iceModelShortUrlHitPeer::IS_MOBILE, $isMobile, $comparison);
+ }
- /**
- * Filter the query by a related iceModelShortUrl object
- *
- * @param iceModelShortUrl|PropelCollection $iceModelShortUrl The related object(s) to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return iceModelShortUrlHitQuery The current query, for fluid interface
- */
- public function filterByiceModelShortUrl($iceModelShortUrl, $comparison = null)
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ * <code>
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ * </code>
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return iceModelShortUrlHitQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt))
{
- if ($iceModelShortUrl instanceof iceModelShortUrl) {
- return $this
- ->addUsingAlias(iceModelShortUrlHitPeer::SHORT_URL_ID, $iceModelShortUrl->getId(), $comparison);
- } elseif ($iceModelShortUrl instanceof PropelCollection) {
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
- return $this
- ->addUsingAlias(iceModelShortUrlHitPeer::SHORT_URL_ID, $iceModelShortUrl->toKeyValue('PrimaryKey', 'Id'), $comparison);
- } else {
- throw new PropelException('filterByiceModelShortUrl() only accepts arguments of type iceModelShortUrl or PropelCollection');
- }
+ $useMinMax = false;
+ if (isset($createdAt['min']))
+ {
+ $this->addUsingAlias(iceModelShortUrlHitPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max']))
+ {
+ $this->addUsingAlias(iceModelShortUrlHitPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax)
+ {
+ return $this;
+ }
+ if (null === $comparison)
+ {
+ $comparison = Criteria::IN;
+ }
}
+ return $this->addUsingAlias(iceModelShortUrlHitPeer::CREATED_AT, $createdAt, $comparison);
+ }
- /**
- * Adds a JOIN clause to the query using the iceModelShortUrl relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return iceModelShortUrlHitQuery The current query, for fluid interface
- */
- public function joiniceModelShortUrl($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ * <code>
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ * </code>
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return iceModelShortUrlHitQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt))
{
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('iceModelShortUrl');
+ $useMinMax = false;
+ if (isset($updatedAt['min']))
+ {
+ $this->addUsingAlias(iceModelShortUrlHitPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max']))
+ {
+ $this->addUsingAlias(iceModelShortUrlHitPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax)
+ {
+ return $this;
+ }
+ if (null === $comparison)
+ {
+ $comparison = Criteria::IN;
+ }
+ }
+ return $this->addUsingAlias(iceModelShortUrlHitPeer::UPDATED_AT, $updatedAt, $comparison);
+ }
- // create a ModelJoin object for this join
- $join = new ModelJoin();
- $join->setJoinType($joinType);
- $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
- if ($previousJoin = $this->getPreviousJoin()) {
- $join->setPreviousJoin($previousJoin);
- }
+ /**
+ * Filter the query by a related iceModelShortUrl object
+ *
+ * @param iceModelShortUrl|PropelCollection $iceModelShortUrl The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return iceModelShortUrlHitQuery The current query, for fluid interface
+ */
+ public function filterByiceModelShortUrl($iceModelShortUrl, $comparison = null)
+ {
+ if ($iceModelShortUrl instanceof iceModelShortUrl)
+ {
+ return $this
+ ->addUsingAlias(iceModelShortUrlHitPeer::SHORT_URL_ID, $iceModelShortUrl->getId(), $comparison);
+ }
+ elseif ($iceModelShortUrl instanceof PropelCollection)
+ {
+ if (null === $comparison)
+ {
+ $comparison = Criteria::IN;
+ }
+ return $this
+ ->addUsingAlias(iceModelShortUrlHitPeer::SHORT_URL_ID, $iceModelShortUrl->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ }
+ else
+ {
+ throw new PropelException('filterByiceModelShortUrl() only accepts arguments of type iceModelShortUrl or PropelCollection');
+ }
+ }
- // add the ModelJoin to the current object
- if($relationAlias) {
- $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
- $this->addJoinObject($join, $relationAlias);
- } else {
- $this->addJoinObject($join, 'iceModelShortUrl');
- }
+ /**
+ * Adds a JOIN clause to the query using the iceModelShortUrl relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return iceModelShortUrlHitQuery The current query, for fluid interface
+ */
+ public function joiniceModelShortUrl($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('iceModelShortUrl');
- return $this;
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin())
+ {
+ $join->setPreviousJoin($previousJoin);
}
- /**
- * Use the iceModelShortUrl relation iceModelShortUrl object
- *
- * @see useQuery()
- *
- * @param string $relationAlias optional alias for the relation,
- * to be used as main alias in the secondary query
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return iceModelShortUrlQuery A secondary query class using the current class as primary query
- */
- public function useiceModelShortUrlQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ // add the ModelJoin to the current object
+ if($relationAlias)
{
- return $this
- ->joiniceModelShortUrl($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'iceModelShortUrl', 'iceModelShortUrlQuery');
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
}
-
- /**
- * Exclude object from result
- *
- * @param iceModelShortUrlHit $iceModelShortUrlHit Object to remove from the list of results
- *
- * @return iceModelShortUrlHitQuery The current query, for fluid interface
- */
- public function prune($iceModelShortUrlHit = null)
+ else
{
- if ($iceModelShortUrlHit) {
- $this->addUsingAlias(iceModelShortUrlHitPeer::ID, $iceModelShortUrlHit->getId(), Criteria::NOT_EQUAL);
- }
+ $this->addJoinObject($join, 'iceModelShortUrl');
+ }
- return $this;
+ return $this;
+ }
+
+ /**
+ * Use the iceModelShortUrl relation iceModelShortUrl object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return iceModelShortUrlQuery A secondary query class using the current class as primary query
+ */
+ public function useiceModelShortUrlQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joiniceModelShortUrl($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'iceModelShortUrl', 'iceModelShortUrlQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param iceModelShortUrlHit $iceModelShortUrlHit Object to remove from the list of results
+ *
+ * @return iceModelShortUrlHitQuery The current query, for fluid interface
+ */
+ public function prune($iceModelShortUrlHit = null)
+ {
+ if ($iceModelShortUrlHit)
+ {
+ $this->addUsingAlias(iceModelShortUrlHitPeer::ID, $iceModelShortUrlHit->getId(), Criteria::NOT_EQUAL);
}
+ return $this;
+ }
+
// timestampable behavior
/**
View
16 lib/model/om/BaseiceModelShortUrlPeer.php
@@ -20,9 +20,6 @@
/** the related Propel class for this table */
const OM_CLASS = 'iceModelShortUrl';
- /** A class that can be returned by this peer. */
- const CLASS_DEFAULT = 'plugins.iceShortUrlPlugin.lib.model.iceModelShortUrl';
-
/** the related TableMap class for this table */
const TM_CLASS = 'iceModelShortUrlTableMap';
@@ -472,7 +469,7 @@ public static function populateObjects(PDOStatement $stmt)
$results = array();
// set the class once to avoid overhead in the loop
- $cls = iceModelShortUrlPeer::getOMClass(false);
+ $cls = iceModelShortUrlPeer::getOMClass();
// populate the object(s)
while ($row = $stmt->fetch(PDO::FETCH_NUM))
{
@@ -551,17 +548,12 @@ public static function buildTableMap()
/**
* The class that the Peer will make instances of.
*
- * If $withPrefix is true, the returned path
- * uses a dot-path notation which is tranalted into a path
- * relative to a location on the PHP include_path.
- * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
- * @param boolean $withPrefix Whether or not to return the path with the class name
- * @return string path.to.ClassName
+ * @return string ClassName
*/
- public static function getOMClass($withPrefix = true)
+ public static function getOMClass()
{
- return $withPrefix ? iceModelShortUrlPeer::CLASS_DEFAULT : iceModelShortUrlPeer::OM_CLASS;
+ return iceModelShortUrlPeer::OM_CLASS;
}
/**
View
963 lib/model/om/BaseiceModelShortUrlQuery.php
@@ -61,485 +61,602 @@
*/
abstract class BaseiceModelShortUrlQuery extends ModelCriteria
{
-
- /**
- * Initializes internal state of BaseiceModelShortUrlQuery object.
- *
- * @param string $dbName The dabase name
- * @param string $modelName The phpName of a model, e.g. 'Book'
- * @param string $modelAlias The alias for the model in this query, e.g. 'b'
- */
- public function __construct($dbName = 'propel', $modelName = 'iceModelShortUrl', $modelAlias = null)
+
+ /**
+ * Initializes internal state of BaseiceModelShortUrlQuery object.
+ *
+ * @param string $dbName The dabase name
+ * @param string $modelName The phpName of a model, e.g. 'Book'
+ * @param string $modelAlias The alias for the model in this query, e.g. 'b'
+ */
+ public function __construct($dbName = 'propel', $modelName = 'iceModelShortUrl', $modelAlias = null)
+ {
+ parent::__construct($dbName, $modelName, $modelAlias);
+ }
+
+ /**
+ * Returns a new iceModelShortUrlQuery object.
+ *
+ * @param string $modelAlias The alias of a model in the query
+ * @param Criteria $criteria Optional Criteria to build the query from
+ *
+ * @return iceModelShortUrlQuery
+ */
+ public static function create($modelAlias = null, $criteria = null)
+ {
+ if ($criteria instanceof iceModelShortUrlQuery)
{
- parent::__construct($dbName, $modelName, $modelAlias);
+ return $criteria;
}
-
- /**
- * Returns a new iceModelShortUrlQuery object.
- *
- * @param string $modelAlias The alias of a model in the query
- * @param Criteria $criteria Optional Criteria to build the query from
- *
- * @return iceModelShortUrlQuery
- */
- public static function create($modelAlias = null, $criteria = null)
+ $query = new iceModelShortUrlQuery();
+ if (null !== $modelAlias)
{
- if ($criteria instanceof iceModelShortUrlQuery) {
- return $criteria;
- }
- $query = new iceModelShortUrlQuery();
- if (null !== $modelAlias) {
- $query->setModelAlias($modelAlias);
- }
- if ($criteria instanceof Criteria) {
- $query->mergeWith($criteria);
- }
- return $query;
+ $query->setModelAlias($modelAlias);
}
-
- /**
- * Find object by primary key
- * Use instance pooling to avoid a database query if the object exists
- * <code>
- * $obj = $c->findPk(12, $con);
- * </code>
- * @param mixed $key Primary key to use for the query
- * @param PropelPDO $con an optional connection object
- *
- * @return iceModelShortUrl|array|mixed the result, formatted by the current formatter
- */
- public function findPk($key, $con = null)
+ if ($criteria instanceof Criteria)
{
- if ((null !== ($obj = iceModelShortUrlPeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) {
- // the object is alredy in the instance pool
- return $obj;
- } else {
- // the object has not been requested yet, or the formatter is not an object formatter
- $criteria = $this->isKeepQuery() ? clone $this : $this;
- $stmt = $criteria
- ->filterByPrimaryKey($key)
- ->getSelectStatement($con);
- return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
- }
+ $query->mergeWith($criteria);
}
+ return $query;
+ }
- /**
- * Find objects by primary key
- * <code>
- * $objs = $c->findPks(array(12, 56, 832), $con);
- * </code>
- * @param array $keys Primary keys to use for the query
- * @param PropelPDO $con an optional connection object
- *
- * @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
- */
- public function findPks($keys, $con = null)
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ * <code>
+ * $obj = $c->findPk(12, $con);
+ * </code>
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return iceModelShortUrl|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null)
{
- $criteria = $this->isKeepQuery() ? clone $this : $this;
- return $this
- ->filterByPrimaryKeys($keys)
- ->find($con);
+ return null;
}
-
- /**
- * Filter the query by primary key
- *
- * @param mixed $key Primary key to use for the query
- *
- * @return iceModelShortUrlQuery The current query, for fluid interface
- */
- public function filterByPrimaryKey($key)
+ if ((null !== ($obj = iceModelShortUrlPeer::getInstanceFromPool((string) $key))) && !$this->formatter)
{
- return $this->addUsingAlias(iceModelShortUrlPeer::ID, $key, Criteria::EQUAL);
+ // the object is alredy in the instance pool
+ return $obj;
}
-
- /**
- * Filter the query by a list of primary keys
- *
- * @param array $keys The list of primary key to use for the query
- *
- * @return iceModelShortUrlQuery The current query, for fluid interface
- */
- public function filterByPrimaryKeys($keys)
+ if ($con === null)
+ {
+ $con = Propel::getConnection(iceModelShortUrlPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ }
+ else
{
- return $this->addUsingAlias(iceModelShortUrlPeer::ID, $keys, Criteria::IN);
+ return $this->findPkSimple($key, $con);
}
+ }
- /**
- * Filter the query on the id column
- *
- * Example usage:
- * <code>
- * $query->filterById(1234); // WHERE id = 1234
- * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
- * $query->filterById(array('min' => 12)); // WHERE id > 12
- * </code>
- *
- * @param mixed $id The value to use as filter.
- * Use scalar values for equality.
- * Use array values for in_array() equivalent.
- * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return iceModelShortUrlQuery The current query, for fluid interface
- */
- public function filterById($id = null, $comparison = null)
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return iceModelShortUrl A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `ID`, `URL`, `URL_DECODED`, `HASH`, `VIEW_COUNT`, `IS_PUBLIC`, `IS_ENABLED`, `CREATED_AT`, `UPDATED_AT` FROM `short_url` WHERE `ID` = :p0';
+ try
{
- if (is_array($id) && null === $comparison) {
- $comparison = Criteria::IN;
- }
- return $this->addUsingAlias(iceModelShortUrlPeer::ID, $id, $comparison);
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
}
+ catch (Exception $e)
+ {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM))
+ {
+ $obj = new iceModelShortUrl();
+ $obj->hydrate($row);
+ iceModelShortUrlPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return iceModelShortUrl|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
- /**
- * Filter the query on the url column
- *
- * Example usage:
- * <code>
- * $query->filterByUrl('fooValue'); // WHERE url = 'fooValue'
- * $query->filterByUrl('%fooValue%'); // WHERE url LIKE '%fooValue%'
- * </code>
- *
- * @param string $url The value to use as filter.
- * Accepts wildcards (* and % trigger a LIKE)
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return iceModelShortUrlQuery The current query, for fluid interface
- */
- public function filterByUrl($url = null, $comparison = null)
+ /**
+ * Find objects by primary key
+ * <code>
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ * </code>
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null)
{
- if (null === $comparison) {
- if (is_array($url)) {
- $comparison = Criteria::IN;
- } elseif (preg_match('/[\%\*]/', $url)) {
- $url = str_replace('*', '%', $url);
- $comparison = Criteria::LIKE;
- }
- }
- return $this->addUsingAlias(iceModelShortUrlPeer::URL, $url, $comparison);
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
}
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return iceModelShortUrlQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ return $this->addUsingAlias(iceModelShortUrlPeer::ID, $key, Criteria::EQUAL);
+ }
- /**
- * Filter the query on the url_decoded column
- *
- * Example usage:
- * <code>
- * $query->filterByUrlDecoded('fooValue'); // WHERE url_decoded = 'fooValue'
- * $query->filterByUrlDecoded('%fooValue%'); // WHERE url_decoded LIKE '%fooValue%'
- * </code>
- *
- * @param string $urlDecoded The value to use as filter.
- * Accepts wildcards (* and % trigger a LIKE)
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return iceModelShortUrlQuery The current query, for fluid interface
- */
- public function filterByUrlDecoded($urlDecoded = null, $comparison = null)
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return iceModelShortUrlQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ return $this->addUsingAlias(iceModelShortUrlPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ * <code>
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ * </code>
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return iceModelShortUrlQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id) && null === $comparison)
{
- if (null === $comparison) {
- if (is_array($urlDecoded)) {
- $comparison = Criteria::IN;
- } elseif (preg_match('/[\%\*]/', $urlDecoded)) {
- $urlDecoded = str_replace('*', '%', $urlDecoded);
- $comparison = Criteria::LIKE;
- }
- }
- return $this->addUsingAlias(iceModelShortUrlPeer::URL_DECODED, $urlDecoded, $comparison);
+ $comparison = Criteria::IN;
}
+ return $this->addUsingAlias(iceModelShortUrlPeer::ID, $id, $comparison);
+ }
- /**
- * Filter the query on the hash column
- *
- * Example usage:
- * <code>
- * $query->filterByHash('fooValue'); // WHERE hash = 'fooValue'
- * $query->filterByHash('%fooValue%'); // WHERE hash LIKE '%fooValue%'
- * </code>
- *
- * @param string $hash The value to use as filter.
- * Accepts wildcards (* and % trigger a LIKE)
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return iceModelShortUrlQuery The current query, for fluid interface
- */
- public function filterByHash($hash = null, $comparison = null)
+ /**
+ * Filter the query on the url column
+ *
+ * Example usage:
+ * <code>
+ * $query->filterByUrl('fooValue'); // WHERE url = 'fooValue'
+ * $query->filterByUrl('%fooValue%'); // WHERE url LIKE '%fooValue%'
+ * </code>
+ *
+ * @param string $url The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return iceModelShortUrlQuery The current query, for fluid interface
+ */
+ public function filterByUrl($url = null, $comparison = null)
+ {
+ if (null === $comparison)
{
- if (null === $comparison) {
- if (is_array($hash)) {
- $comparison = Criteria::IN;
- } elseif (preg_match('/[\%\*]/', $hash)) {
- $hash = str_replace('*', '%', $hash);
- $comparison = Criteria::LIKE;
- }
- }
- return $this->addUsingAlias(iceModelShortUrlPeer::HASH, $hash, $comparison);
+ if (is_array($url))
+ {
+ $comparison = Criteria::IN;
+ }
+ elseif (preg_match('/[\%\*]/', $url))
+ {
+ $url = str_replace('*', '%', $url);
+ $comparison = Criteria::LIKE;
+ }
}
+ return $this->addUsingAlias(iceModelShortUrlPeer::URL, $url, $comparison);
+ }
- /**
- * Filter the query on the view_count column
- *
- * Example usage:
- * <code>
- * $query->filterByViewCount(1234); // WHERE view_count = 1234
- * $query->filterByViewCount(array(12, 34)); // WHERE view_count IN (12, 34)
- * $query->filterByViewCount(array('min' => 12)); // WHERE view_count > 12
- * </code>
- *
- * @param mixed $viewCount The value to use as filter.