Class Phalcon\Mvc\Model\Criteria
implements Phalcon\Mvc\Model\CriteriaInterface, Phalcon\Di\InjectionAwareInterface
This class is used to build the array parameter required by Phalcon\Mvc\Model::find() and Phalcon\Mvc\Model::findFirst() using an object-oriented interface.
<?php
$robots = Robots::query()
->where("type = :type:")
->andWhere("year < 2000")
->bind(array("type" => "mechanical"))
->limit(5, 10)
->order("name")
->execute();
Methods
public setDI (unknown $dependencyInjector)
Sets the DependencyInjector container
public Phalcon\DiInterface getDI ()
Returns the DependencyInjector container
public Phalcon\Mvc\Model\Criteria setModelName (unknown $modelName)
Set a model on which the query will be executed
public string getModelName ()
Returns an internal model name on which the criteria will be applied
public Phalcon\Mvc\Model\Criteria bind (unknown $bindParams)
Sets the bound parameters in the criteria This method replaces all previously set bound parameters
public Phalcon\Mvc\Model\Criteria bindTypes (unknown $bindTypes)
Sets the bind types in the criteria This method replaces all previously set bound parameters
public Phalcon\Mvc\Model\Criteria columns (unknown $columns)
Sets the columns to be queried
<?php
$criteria->columns(array('id', 'name'));
public Phalcon\Mvc\Model\Criteria join (unknown $model, [unknown $conditions], [unknown $alias], [unknown $type])
Adds a INNER join to the query
<?php
$criteria->join('Robots');
$criteria->join('Robots', 'r.id = RobotsParts.robots_id');
$criteria->join('Robots', 'r.id = RobotsParts.robots_id', 'r');
$criteria->join('Robots', 'r.id = RobotsParts.robots_id', 'r', 'LEFT');
public Phalcon\Mvc\Model\Criteria innerJoin (unknown $model, [unknown $conditions], [unknown $alias])
Adds a INNER join to the query
<?php
$criteria->innerJoin('Robots');
$criteria->innerJoin('Robots', 'r.id = RobotsParts.robots_id');
$criteria->innerJoin('Robots', 'r.id = RobotsParts.robots_id', 'r');
public Phalcon\Mvc\Model\Criteria leftJoin (unknown $model, [unknown $conditions], [unknown $alias])
Adds a LEFT join to the query
<?php
$criteria->leftJoin('Robots', 'r.id = RobotsParts.robots_id', 'r');
public Phalcon\Mvc\Model\Criteria rightJoin (unknown $model, [unknown $conditions], [unknown $alias])
Adds a RIGHT join to the query
<?php
$criteria->rightJoin('Robots', 'r.id = RobotsParts.robots_id', 'r');
public Phalcon\Mvc\Model\Criteria where (unknown $conditions, [unknown $bindParams], [unknown $bindTypes])
Sets the conditions parameter in the criteria
public Phalcon\Mvc\Model\Criteria addWhere (unknown $conditions, [unknown $bindParams], [unknown $bindTypes])
Appends a condition to the current conditions using an AND operator (deprecated)
public Phalcon\Mvc\Model\Criteria andWhere (unknown $conditions, [unknown $bindParams], [unknown $bindTypes])
Appends a condition to the current conditions using an AND operator
public Phalcon\Mvc\Model\Criteria orWhere (unknown $conditions, [unknown $bindParams], [unknown $bindTypes])
Appends a condition to the current conditions using an OR operator
public Phalcon\Mvc\Model\Criteria betweenWhere (unknown $expr, unknown $minimum, unknown $maximum)
Appends a BETWEEN condition to the current conditions
<?php
$criteria->betweenWhere('price', 100.25, 200.50);
public Phalcon\Mvc\Model\Criteria notBetweenWhere (unknown $expr, unknown $minimum, unknown $maximum)
Appends a NOT BETWEEN condition to the current conditions
<?php
$criteria->notBetweenWhere('price', 100.25, 200.50);
public Phalcon\Mvc\Model\Criteria inWhere (unknown $expr, unknown $values)
Appends an IN condition to the current conditions
<?php
$criteria->inWhere('id', [1, 2, 3]);
public Phalcon\Mvc\Model\Criteria notInWhere (unknown $expr, unknown $values)
Appends a NOT IN condition to the current conditions
<?php
$criteria->notInWhere('id', [1, 2, 3]);
public Phalcon\Mvc\Model\Criteria conditions (unknown $conditions)
Adds the conditions parameter to the criteria
public Phalcon\Mvc\Model\Criteria order (unknown $orderColumns)
Adds the order-by parameter to the criteria (deprecated)
public Phalcon\Mvc\Model\Criteria orderBy (unknown $orderColumns)
Adds the order-by parameter to the criteria
public Phalcon\Mvc\Model\Criteria limit (unknown $limit, [unknown $offset])
Adds the limit parameter to the criteria
public Phalcon\Mvc\Model\Criteria forUpdate ([unknown $forUpdate])
Adds the “for_update” parameter to the criteria
public Phalcon\Mvc\Model\Criteria sharedLock ([unknown $sharedLock])
Adds the “shared_lock” parameter to the criteria
public Phalcon\Mvc\Model\Criteria cache (unknown $cache)
Sets the cache options in the criteria This method replaces all previously set cache options
public string|null getWhere ()
Returns the conditions parameter in the criteria
public string|array|null getColumns ()
Returns the columns to be queried
public string|null getConditions ()
Returns the conditions parameter in the criteria
public int|array|null getLimit ()
Returns the limit parameter in the criteria, which will be an integer if limit was set without an offset, an array with ‘number’ and ‘offset’ keys if an offset was set with the limit, or null if limit has not been set.
public string|null getOrder ()
Returns the order parameter in the criteria
public array getParams ()
Returns all the parameters defined in the criteria
public static Phalcon\Mvc\Model\Criteria fromInput (unknown $dependencyInjector, unknown $modelName, unknown $data)
Builds a Phalcon\Mvc\Model\Criteria based on an input array like _POST
public Phalcon\Mvc\Model\ResultsetInterface execute ()
Executes a find using the parameters built with the criteria