extends abstract class Phalcon\Di\Injectable
implements Phalcon\Events\EventsAwareInterface, Phalcon\Di\InjectionAwareInterface, Phalcon\Mvc\Model\QueryInterface
This class takes a PHQL intermediate representation and executes it.
<?php
$phql = "SELECT c.price*0.16 AS taxes, c.* FROM Cars AS c JOIN Brands AS b
WHERE b.name = :name: ORDER BY c.name";
$result = $manager->executeQuery($phql, array(
'name' => 'Lamborghini'
));
foreach ($result as $row) {
echo "Name: ", $row->cars->name, "\n";
echo "Price: ", $row->cars->price, "\n";
echo "Taxes: ", $row->taxes, "\n";
}
public __construct (string $phql)
Phalcon\Mvc\Model\Query constructor
public setPhql ([unknown $phql])
...
public getPhql ()
...
public Phalcon\Mvc\Model\ManagerInterface getModelsManager ()
Returns the models manager related to the entity instance
public Phalcon\Mvc\Model\MetaDataInterface getModelsMetaData ()
Returns the models meta-data service related to the entity instance
public Phalcon\Mvc\Model\Query 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
protected string _getQualified ()
Replaces the model’s name to its source name in a qualifed-name expression
protected string _getCallArgument ()
Resolves a expression in a single call argument
protected string _getCaseExpression ()
Resolves a expression in a single call argument
protected string _getFunctionCall ()
Resolves a expression in a single call argument
protected string _getExpression ()
Resolves an expression from its intermediate code into a string
protected array _getSelectColumn ()
Resolves a column from its intermediate representation into an array used to determine if the resulset produced is simple or complex
protected string _getTable ()
Resolves a table in a SELECT statement checking if the model exists
protected array _getJoin ()
Resolves a JOIN clause checking if the associated models exist
protected string _getJoinType ()
Resolves a JOIN type
protected array _getSingleJoin ()
Resolves joins involving has-one/belongs-to/has-many relations
protected array _getMultiJoin ()
Resolves joins involving many-to-many relations
protected array _getJoins ()
Processes the JOINs in the query returning an internal representation for the database dialect
protected string _getOrderClause ()
Returns a processed order clause for a SELECT statement
protected string _getGroupClause ()
Returns a processed group clause for a SELECT statement
protected _getLimitClause ()
...
protected array _prepareSelect ()
Analyzes a SELECT intermediate code and produces an array to be executed later
protected array _prepareInsert ()
Analyzes an INSERT intermediate code and produces an array to be executed later
protected array _prepareUpdate ()
Analyzes an UPDATE intermediate code and produces an array to be executed later
protected array _prepareDelete ()
Analyzes a DELETE intermediate code and produces an array to be executed later
public array parse ()
Parses the intermediate code produced by Phalcon\Mvc\Model\Query\Lang generating another intermediate representation that could be executed by Phalcon\Mvc\Model\Query
public Phalcon\Mvc\Model\Query cache (array $cacheOptions)
Sets the cache parameters of the query
public getCacheOptions ()
Returns the current cache options
public Phalcon\Cache\BackendInterface getCache ()
Returns the current cache backend instance
public Phalcon\Mvc\Model\Query ignoreLastInsertId ()
Ignore last insert id
protected Phalcon\Mvc\Model\ResultsetInterface _executeSelect ()
Executes the SELECT intermediate representation producing a Phalcon\Mvc\Model\Resultset
protected Phalcon\Mvc\Model\Query\StatusInterface _executeInsert ()
Executes the INSERT intermediate representation producing a Phalcon\Mvc\Model\Query\Status
protected Phalcon\Mvc\Model\Query\StatusInterface _executeUpdate ()
Executes the UPDATE intermediate representation producing a Phalcon\Mvc\Model\Query\Status
protected Phalcon\Mvc\Model\Query\StatusInterface _executeDelete ()
Executes the DELETE intermediate representation producing a Phalcon\Mvc\Model\Query\Status
public mixed execute ([array $bindParams], [array $bindTypes], [unknown $useRawsql])
Executes a parsed PHQL statement
public Phalcon\Mvc\ModelInterface getSingleResult ([array $bindParams], [array $bindTypes])
Executes the query returning the first result
public Phalcon\Mvc\Model\Query setType (int $type)
Sets the type of PHQL statement to be executed
public int getType ()
Gets the type of PHQL statement executed
public mixed getBindParam (string $name)
Get bind parameter
public Phalcon\Mvc\Model\Query setBindParams (array $bindParams)
Set default bind parameters
public array getBindParams ()
Returns default bind params
public Phalcon\Mvc\Model\Query setMergeBindParams (array $bindParams)
Set merge bind parameters
public array getMergeBindParams ()
Returns merge bind params
public Phalcon\Mvc\Model\Query setBindType (string $name, int $type)
Set bind type
public Phalcon\Mvc\Model\Query setBindTypes (array $bindTypes)
Set default bind types
public array getBindTypes ()
Returns default bind types
public Phalcon\Mvc\Model\Query setMergeBindTypes (array $bindTypes)
Set merge bind types
public array getMergeBindTypes ()
Returns default bind types
public Phalcon\Mvc\Model\Query setIndex (string $index)
Adds the index
public string getIndex ()
Gets the index
public Phalcon\Mvc\Model\Query setIntermediate (array $intermediate)
Allows to set the IR to be executed
public array getIntermediate ()
Returns the intermediate representation of the PHQL statement
public array getModels ()
Returns the models of the PHQL statement
public Phalcon\Mvc\Model\Query setConnection (Phalcon\Db\AdapterInterface $connection)
Sets the connection
public mixed getConnection ()
Gets the connection
public mixed getReadConnection ([array $intermediate], [array $bindParams], [array $bindTypes])
Gets the read connection
public mixed getWriteConnection ([array $intermediate], [array $bindParams], [array $bindTypes])
Gets the write connection
public Phalcon\Mvc\Model\Query setConflict (array $conflict)
Sets conflict
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
...