91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

laravel cursor的底層實現

發布時間:2020-03-18 12:35:34 來源:網絡 閱讀:2750 作者:hgditren 欄目:web開發
foreach (BillInfo::where('id', '>', 0)->orderBy('id', 'desc')->limit(10000)->cursor() as $value) {
   print_r($value);
}


Illuminate\Database\Query\Builder.php;
/**
* Get a generator for the given query.
*
* @return \Generator
*/
public function cursor()
{
   if (is_null($this->columns)) {
       $this->columns = ['*'];
   }

   return $this->connection->cursor(
       $this->toSql(), $this->getBindings(), ! $this->useWritePdo
   );
}


Illuminate\Database\Connection.php;
/**
* Run a select statement against the database and returns a generator.
*
* @param  string  $query
* @param  array  $bindings
* @param  bool  $useReadPdo
* @return \Generator
*/
public function cursor($query, $bindings = [], $useReadPdo = true)
{
   $statement = $this->run($query, $bindings, function ($query, $bindings) use ($useReadPdo) {
       if ($this->pretending()) {
           return [];
       }

       // First we will create a statement for the query. Then, we will set the fetch
       // mode and prepare the bindings for the query. Once that's done we will be
       // ready to execute the query against the database and return the cursor.
       $statement = $this->prepared($this->getPdoForSelect($useReadPdo)
                         ->prepare($query));

       $this->bindValues(
           $statement, $this->prepareBindings($bindings)
       );

       // Next, we'll execute the query against the database and return the statement
       // so we can return the cursor. The cursor will use a PHP generator to give
       // back one row at a time without using a bunch of memory to render them.
       $statement->execute();

       return $statement;
   });

   while ($record = $statement->fetch()) {
       yield $record;
   }
}
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

根河市| 临猗县| 浮山县| 新营市| 栖霞市| 长宁县| 名山县| 政和县| 调兵山市| 旅游| 栖霞市| 漳浦县| 华宁县| 卢湾区| 荔波县| 临桂县| 高安市| 江川县| 聂荣县| 新源县| 巴楚县| 余庆县| 康保县| 锡林浩特市| 富锦市| 雅江县| 宜宾市| 涪陵区| 古丈县| 虎林市| 黄山市| 高阳县| 黄大仙区| 历史| 布尔津县| 双柏县| 辉县市| 崇仁县| 广德县| 华池县| 永康市|