run() public method

Executes the provided query after compiling it for the specific driver dialect and returns the executed Statement object.
public run ( Query $query ) : Cake\Database\StatementInterface
$query Query The query to be executed
return Cake\Database\StatementInterface executed statement
Example #1
0
 /**
  * Compiles the SQL representation of this query and executes it using the
  * configured connection object. Returns the resulting statement object.
  *
  * Executing a query internally executes several steps, the first one is
  * letting the connection transform this object to fit its particular dialect,
  * this might result in generating a different Query object that will be the one
  * to actually be executed. Immediately after, literal values are passed to the
  * connection so they are bound to the query in a safe way. Finally, the resulting
  * statement is decorated with custom objects to execute callbacks for each row
  * retrieved if necessary.
  *
  * Resulting statement is traversable, so it can be used in any loop as you would
  * with an array.
  *
  * This method can be overridden in query subclasses to decorate behavior
  * around query execution.
  *
  * @return \Cake\Database\StatementInterface
  */
 public function execute()
 {
     $statement = $this->_connection->run($this);
     return $this->_iterator = $this->_decorateStatement($statement);
 }