示例#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);
     $this->_iterator = $this->_decorateStatement($statement);
     $this->_dirty = false;
     return $this->_iterator;
 }
示例#2
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);
     $driver = $this->_connection->driver();
     $typeMap = $this->selectTypeMap();
     if ($typeMap->toArray()) {
         $this->decorateResults(new FieldTypeConverter($typeMap, $driver));
     }
     $this->_iterator = $this->_decorateStatement($statement);
     $this->_dirty = false;
     return $this->_iterator;
 }