當前位置: 首頁>>代碼示例>>PHP>>正文


PHP resource::fetchAll方法代碼示例

本文整理匯總了PHP中resource::fetchAll方法的典型用法代碼示例。如果您正苦於以下問題:PHP resource::fetchAll方法的具體用法?PHP resource::fetchAll怎麽用?PHP resource::fetchAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在resource的用法示例。


在下文中一共展示了resource::fetchAll方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: load

 /**
  * Load a value from cache.
  *
  * @param  string $id
  * @param  string $time
  * @return mixed
  */
 public function load($id, $time)
 {
     $value = false;
     // Determine if the value already exists.
     $rows = [];
     $this->prepare("SELECT * FROM " . $this->table . " WHERE id = :id")->bindParams(['id' => sha1($id)])->execute();
     if ($this->isPdo) {
         while (($row = $this->result->fetchAll(\PDO::FETCH_ASSOC)) != false) {
             $rows[] = $row;
         }
     } else {
         while (($row = $this->result->fetchArray(SQLITE3_ASSOC)) != false) {
             $rows[] = $row;
         }
     }
     // If the value is found, check expiration and return.
     if (count($rows) > 0) {
         $data = $rows[0]['value'];
         $timestamp = $rows[0]['time'];
         if ($timestamp == 0 || time() - $timestamp <= $time) {
             $value = unserialize($data);
         }
     }
     return $value;
 }
開發者ID:Nnadozieomeonu,項目名稱:lacecart,代碼行數:32,代碼來源:Sqlite.php

示例2: getAll

 /**
  * Get the all records as an associative array with fields names as keys.
  *
  * @return array()
  * @access public
  */
 public function getAll($fetchMode = PDO::FETCH_BOTH, $column = 0)
 {
     if ($fetchMode & PDO::FETCH_COLUMN > 0) {
         return $this->_result->fetchAll($fetchMode, $column);
     } else {
         return $this->_result->fetchAll($fetchMode);
     }
 }
開發者ID:davidmottet,項目名稱:automne,代碼行數:14,代碼來源:query.php

示例3: getLifetime

 /**
  * Get the lifetime of the value.
  *
  * @param  string $id
  * @return int
  */
 public function getLifetime($id)
 {
     // Determine if the value already exists.
     $rows = [];
     $value = 0;
     $this->prepare('SELECT * FROM "' . $this->table . '" WHERE "id" = :id')->bindParams(['id' => sha1($id)])->execute();
     if ($this->isPdo) {
         while (($row = $this->result->fetchAll(\PDO::FETCH_ASSOC)) != false) {
             $rows[] = $row;
         }
     } else {
         while (($row = $this->result->fetchArray(SQLITE3_ASSOC)) != false) {
             $rows[] = $row;
         }
     }
     // If the value is found, check expiration and return.
     if (count($rows) > 0) {
         $cacheValue = $rows[0];
         $value = $cacheValue['lifetime'];
     }
     return $value;
 }
開發者ID:popphp,項目名稱:pop-cache,代碼行數:28,代碼來源:Sqlite.php

示例4: __construct

 /**
  * Instantiates an SQLiteResult object from a query.
  * 
  * @param string $result A PDOStatement object.
  * @param int $resultType Controls how the row(s) will be returned.
  */
 public function __construct($result, $resultType = self::RESULT_OBJ)
 {
     $this->result = $result;
     $this->data = $this->result->fetchAll($resultType);
     $this->numRows = count($this->data);
 }
開發者ID:elevenone,項目名稱:SQLiteDatabase,代碼行數:12,代碼來源:SQLiteResult.php


注:本文中的resource::fetchAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。