extends abstract class Phalcon\Di\Injectable
implements Phalcon\Events\EventsAwareInterface, Phalcon\Di\InjectionAwareInterface, Phalcon\Mvc\Model\CriteriaInterface
This class allows 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"))
->order("name")
->execute();
public Phalcon\Mvc\Model\CriteriaInterface setModelName (string $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\CriteriaInterface bind (string $bindParams, [boolean $merge])
Sets the bound parameters in the criteria This method replaces all previously set bound parameters
public Phalcon\Mvc\Model\CriteriaInterface bindTypes (array $bindTypes, [unknown $merge])
Sets the bind types in the criteria This method replaces all previously set bound parameters
public select (unknown $columns)
...
public Phalcon\Mvc\Model\CriteriaInterface columns (string|array $columns)
Sets the columns to be queried
<?php
$criteria->columns(array('id', 'name'));
public string|array getColumns ()
Returns the columns to be queried
public Phalcon\Mvc\Model\CriteriaInterface join (string $model, [string $conditions], [string $alias], [string $type])
Adds a 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\CriteriaInterface innerJoin (string $model, [string $conditions], [string $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');
$criteria->innerJoin('Robots', 'r.id = RobotsParts.robots_id', 'r', 'LEFT');
public Phalcon\Mvc\Model\CriteriaInterface leftJoin (string $model, [string $conditions], [string $alias])
Adds a LEFT join to the query
<?php
$criteria->leftJoin('Robots', 'r.id = RobotsParts.robots_id', 'r');
public Phalcon\Mvc\Model\CriteriaInterface rightJoin (string $model, [string $conditions], [string $alias])
Adds a RIGHT join to the query
<?php
$criteria->rightJoin('Robots', 'r.id = RobotsParts.robots_id', 'r');
public Phalcon\Mvc\Model\CriteriaInterface where (string $conditions, [array $bindParams], [array $bindTypes])
Sets the conditions parameter in the criteria
public Phalcon\Mvc\Model\CriteriaInterface addWhere (string $conditions, [array $bindParams], [array $bindTypes])
Appends a condition to the current conditions using an AND operator (deprecated)
public Phalcon\Mvc\Model\CriteriaInterface andWhere (string $conditions, [array $bindParams], [array $bindTypes])
Appends a condition to the current conditions using an AND operator
public Phalcon\Mvc\Model\CriteriaInterface orWhere (string $conditions, [array $bindParams], [array $bindTypes])
Appends a condition to the current conditions using an OR operator
public Phalcon\Mvc\Model\CriteriaInterface betweenWhere (string $expr, mixed $minimum, mixed $maximum, [boolean $useOrWhere])
Appends a BETWEEN condition to the current conditions
<?php
$criteria->betweenWhere('price', 100.25, 200.50);
public Phalcon\Mvc\Model\CriteriaInterface notBetweenWhere (string $expr, mixed $minimum, mixed $maximum, [boolean $useOrWhere])
Appends a NOT BETWEEN condition to the current conditions
<?php
$criteria->notBetweenWhere('price', 100.25, 200.50);
public Phalcon\Mvc\Model\CriteriaInterface inWhere (string $expr, array $values, [unknown $useOrWhere])
Appends an IN condition to the current conditions
<?php
$criteria->inWhere('id', [1, 2, 3]);
public Phalcon\Mvc\Model\CriteriaInterface notInWhere (string $expr, array $values, [boolean $useOrWhere])
Appends a NOT IN condition to the current conditions
<?php
$criteria->notInWhere('id', [1, 2, 3]);
public string getWhere ()
Returns the conditions parameter in the criteria
public Phalcon\Mvc\Model\CriteriaInterface conditions (string $conditions)
Adds the conditions parameter to the criteria
public string getConditions ()
Returns the conditions parameter in the criteria
public Phalcon\Mvc\Model\CriteriaInterface order (string $orderColumns)
Adds the order-by parameter to the criteria (deprecated)
public Phalcon\Mvc\Model\CriteriaInterface orderBy (string $orderColumns)
Adds the order-by parameter to the criteria
public string getOrder ()
Returns the order parameter in the criteria
public Phalcon\Mvc\Model\CriteriaInterface limit (int $limit, [int $offset])
Adds the limit parameter to the criteria
public int getLimit ()
Returns the limit parameter in the criteria
public Phalcon\Mvc\Model\CriteriaInterface setUniqueRow (boolean $uniqueRow)
Tells to the query if only the first row in the resultset must be returned
public boolean getUniqueRow ()
Check if the query is programmed to get only the first row in the resultset
public Phalcon\Mvc\Model\CriteriaInterface forUpdate ([boolean $forUpdate])
Adds the “for_update” parameter to the criteria
public Phalcon\Mvc\Model\CriteriaInterface setIndex (string $index)
Adds the “index” parameter to the criteria
public string getIndex ()
Gets the index
public Phalcon\Mvc\Model\CriteriaInterface sharedLock ([boolean $sharedLock])
Adds the “shared_lock” parameter to the criteria
public array getParams ()
Returns all the parameters defined in the criteria
public static Phalcon\Mvc\Model\Criteria fromInput (Phalcon\DiInterface $dependencyInjector, string $modelName, array $data)
Builds a Phalcon\Mvc\Model\Criteria based on an input array like $_POST
public static Phalcon\Mvc\Model\Criteria groupBy (string $group)
Sets a GROUP BY clause
public Phalcon\Mvc\Model\Criteria having (string $having)
Sets a HAVING condition clause. You need to escape PHQL reserved words using [ and ] delimiters
public Phalcon\Mvc\Model\ResultsetInterface execute ()
Executes a find using the parameters built with the criteria
public int count ([unknown $column])
Auto sets columns and return execute
public Phalcon\Mvc\Model\CriteriaInterface cache (array $options)
Sets the cache options in the criteria This method replaces all previously set cache options
public Phalcon\Mvc\Model\CriteriaInterface insert ()
Sets insert type of PHQL statement to be executed
public Phalcon\Mvc\Model\CriteriaInterface update ()
Sets update type of PHQL statement to be executed
public Phalcon\Mvc\Model\CriteriaInterface delete ()
Sets update type of PHQL statement to be executed
public string getPhql ()
Returns a PHQL statement built with the criteria
public string _generateSelect ()
Returns a PHQL statement built with the criteria
public string _generateInsert ()
Returns a PHQL statement built with the criteria
public string _generateUpdate ()
Returns a PHQL statement built with the criteria
public string _generateDelete ()
Returns a PHQL statement built with the criteria
public setDI (Phalcon\DiInterface $dependencyInjector) inherited from Phalcon\Di\Injectable
Sets the dependency injector
public Phalcon\DiInterface getDI ([unknown $error], [unknown $notUseDefault]) inherited from Phalcon\Di\Injectable
Returns the internal dependency injector
public setEventsManager (Phalcon\Events\ManagerInterface $eventsManager) inherited from Phalcon\Di\Injectable
Sets the event manager
public Phalcon\Events\ManagerInterface getEventsManager () inherited from Phalcon\Di\Injectable
Returns the internal event manager
public boolean fireEvent (string $eventName, [mixed $data], [unknown $cancelable]) inherited from Phalcon\Di\Injectable
Fires an event, implicitly calls behaviors and listeners in the events manager are notified
public mixed fireEventCancel (string $eventName, [mixed $data], [unknown $cancelable]) inherited from Phalcon\Di\Injectable
Fires an event, can stop the event by returning to the false
public boolean hasService (string $name) inherited from Phalcon\Di\Injectable
Check whether the DI contains a service by a name
public Phalcon\Di\ServiceInterface setService (unknown $name) inherited from Phalcon\Di\Injectable
Sets a service from the DI
public object|null getService (unknown $name) inherited from Phalcon\Di\Injectable
Obtains a service from the DI
public mixed getResolveService (string $name, [array $args], [unknown $noerror], [unknown $noshared]) inherited from Phalcon\Di\Injectable
Resolves the service based on its configuration
public attachEvent (string $eventType, Closure $callback) inherited from Phalcon\Di\Injectable
Attach a listener to the events
public __get (unknown $property) inherited from Phalcon\Di\Injectable
Magic method __get
public __sleep () inherited from Phalcon\Di\Injectable
...
public __debugInfo () inherited from Phalcon\Di\Injectable
...