当前位置: 首页>>代码示例>>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;未经允许,请勿转载。