bufferResults() public method

When enabled the results returned by this Query will be buffered. This enables you to iterate a result set multiple times, or both cache and iterate it. When disabled it will consume less memory as fetched results are not remembered for future iterations. If called with no arguments, it will return whether or not buffering is enabled.
public bufferResults ( boolean | null $enable = null ) : boolean | $this
$enable boolean | null whether or not to enable buffering
return boolean | $this
Ejemplo n.º 1
2
 /**
  * Prepares a sql statement to be executed
  *
  * @param string|\Cake\Database\Query $query The query to prepare.
  * @return \Cake\Database\StatementInterface
  */
 public function prepare($query)
 {
     $this->connect();
     $options = [PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL];
     $isObject = $query instanceof Query;
     if ($isObject && $query->bufferResults() === false) {
         $options = [];
     }
     $statement = $this->_connection->prepare($isObject ? $query->sql() : $query, $options);
     return new SqlserverStatement($statement, $this);
 }
 /**
  * Prepares a sql statement to be executed
  *
  * @param string|\Cake\Database\Query $query The query to prepare.
  * @return \Cake\Database\StatementInterface
  */
 public function prepare($query)
 {
     $this->connect();
     $options = [PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY];
     $isObject = $query instanceof Query;
     if ($isObject && $query->bufferResults() === false) {
         $options = [];
     }
     $statement = $this->_connection->prepare($isObject ? $query->sql() : $query, $options);
     $result = new CustomSqlserverStatement(new SqlserverStatement($statement, $this), $this);
     if ($isObject && $query->bufferResults() === false) {
         $result->bufferResults(false);
     }
     return $result;
 }
Ejemplo n.º 3
1
 /**
  * Prepares a sql statement to be executed
  *
  * @param string|\Cake\Database\Query $query The query to prepare.
  * @return \Cake\Database\StatementInterface
  */
 public function prepare($query)
 {
     $this->connect();
     $isObject = $query instanceof Query;
     $statement = $this->_connection->prepare($isObject ? $query->sql() : $query);
     $result = new SqliteStatement(new PDOStatement($statement, $this), $this);
     if ($isObject && $query->bufferResults() === false) {
         $result->bufferResults(false);
     }
     return $result;
 }
Ejemplo n.º 4
0
 /**
  * Prepares a sql statement to be executed
  *
  * @param string|\Cake\Database\Query $query The query to convert into a statement.
  * @return \Cake\Database\StatementInterface
  */
 public function prepare($query)
 {
     $this->connect();
     $isObject = $query instanceof \Cake\ORM\Query || $query instanceof \Cake\Database\Query;
     $queryStringRaw = $isObject ? $query->sql() : $query;
     Log::write('debug', $queryStringRaw);
     // debug($queryStringRaw);
     $queryString = $this->_fromDualIfy($queryStringRaw);
     list($queryString, $paramMap) = self::convertPositionalToNamedPlaceholders($queryString);
     $innerStatement = $this->_connection->prepare($queryString);
     $statement = $this->_wrapStatement($innerStatement);
     $statement->queryString = $queryStringRaw;
     $statement->paramMap = $paramMap;
     $disableBuffer = false;
     $normalizedQuery = substr(strtolower(trim($queryString, " \t\n\r\v(")), 0, 6);
     if ($normalizedQuery !== 'select') {
         $disableBuffer = true;
     }
     if ($isObject && $query->bufferResults() === false || $disableBuffer) {
         $statement->bufferResults(false);
     }
     return $statement;
 }