当前位置: 首页>>代码示例>>PHP>>正文


PHP resource::fetchArray方法代码示例

本文整理汇总了PHP中resource::fetchArray方法的典型用法代码示例。如果您正苦于以下问题:PHP resource::fetchArray方法的具体用法?PHP resource::fetchArray怎么用?PHP resource::fetchArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在resource的用法示例。


在下文中一共展示了resource::fetchArray方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: count

 /**
  * Get the number of rows in the result set
  *
  * @return int
  */
 public function count()
 {
     switch ($this->mode) {
         case "mysql":
             $rows = $this->result->num_rows;
             break;
         case "postgres":
         case "redshift":
             $rows = pg_num_rows($this->result);
             break;
         case "odbc":
             $rows = odbc_num_rows($this->result);
             # The above function is unreliable, so if we got a zero count then double check it
             if ($rows < 1) {
                 $rows = 0;
                 /**
                  * If it is an update/delete then we just have to trust the odbc_num_rows() result,
                  * however it is some kind of select, then we can manually count the rows returned.
                  */
                 if (odbc_num_fields($this->result) > 0) {
                     $position = $this->position;
                     $this->seek(0);
                     while ($this->getNextRow()) {
                         ++$rows;
                     }
                     $this->seek($position);
                 }
             }
             break;
         case "sqlite":
             $rows = 0;
             while ($this->result->fetchArray()) {
                 $rows++;
             }
             $this->seek($this->position);
             break;
         case "mssql":
             $rows = mssql_num_rows($this->result);
             break;
     }
     if ($rows === false || $rows < 0) {
         throw new \Exception("Failed to get the row count from the result set");
     }
     return $rows;
 }
开发者ID:ian-Tr,项目名称:le-huard,代码行数:50,代码来源:Result.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: _fetch

 /**
  * Fetch an array from a database result set
  *
  * @param resource $res
  * @return array
  */
 protected function _fetch($res)
 {
     return $res->fetchArray(SQLITE3_ASSOC);
 }
开发者ID:djeraseit,项目名称:quickbooks-php,代码行数:10,代码来源:Sqlite3.php

示例5: fetchAll

 /**
  * Fetches a complete result as an object
  *
  * @param resource $result Resultset
  *
  * @throws Exception
  *
  * @return array of stdClass
  */
 public function fetchAll($result)
 {
     $ret = array();
     if (false === $result) {
         throw new Exception('Error while fetching result: ' . $this->error());
     }
     $result->fetchedByPMF = true;
     while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
         $ret[] = (object) $row;
     }
     return $ret;
 }
开发者ID:kapljr,项目名称:Jay-Kaplan-Farmingdale-BCS-Projects,代码行数:21,代码来源:Sqlite3.php

示例6: copyTable

 /**
  * Copies the contents of from_table in the first database into the
  * to a to_table of suitable schema in a second database. It assumes the
  * table exists in both databases
  *
  * @param string $from_table name of the table to be copied from
  * @param resource $from_dbm database resource for the from table
  * @param resource $to_table name of the table to be copied to
  * @param resource $to_dbm database resource for the to table
  */
 static function copyTable($from_table, $from_dbm, $to_table, $to_dbm)
 {
     $sql = "SELECT * FROM {$from_table}";
     if (($result = $from_dbm->execute($sql)) === false) {
         return false;
     }
     while ($row = $from_dbm->fetchArray($result)) {
         $statement = "INSERT INTO {$to_table} VALUES (";
         $comma = "";
         foreach ($row as $col => $value) {
             $statement .= $comma . " '" . $to_dbm->escapeString($value) . "'";
             $comma = ",";
         }
         $statement .= ")";
         if ($to_dbm->execute($statement) === false) {
             return false;
         }
     }
     return true;
 }
开发者ID:yakar,项目名称:yioop,代码行数:30,代码来源:datasource_manager.php

示例7: nextRecord

 public function nextRecord()
 {
     // Coalesce rather than replace common fields.
     if ($data = @$this->handle->fetchArray(SQLITE3_NUM)) {
         foreach ($data as $columnIdx => $value) {
             if (preg_match('/^"([a-z0-9_]+)"\\."([a-z0-9_]+)"$/i', $this->handle->columnName($columnIdx), $matches)) {
                 $columnName = $matches[2];
             } else {
                 if (preg_match('/^"([a-z0-9_]+)"$/i', $this->handle->columnName($columnIdx), $matches)) {
                     $columnName = $matches[1];
                 } else {
                     $columnName = trim($this->handle->columnName($columnIdx), "\"' \t");
                 }
             }
             // $value || !$ouput[$columnName] means that the *last* occurring value is shown
             // !$ouput[$columnName] means that the *first* occurring value is shown
             if (isset($value) || !isset($output[$columnName])) {
                 $output[$columnName] = is_null($value) ? null : (string) $value;
             }
         }
         return $output;
     } else {
         return false;
     }
 }
开发者ID:rodneyway,项目名称:front-end-workflow-testing,代码行数:25,代码来源:SQLite3Database.php

示例8: fetchAll

 /**
  * Returns an array containing all of the result set rows
  *
  * @param integer $fetchStyle           Controls how the next row will be returned to the caller.
  *                                      This value must be one of the Doctrine_Core::FETCH_* constants,
  *                                      defaulting to Doctrine_Core::FETCH_BOTH
  *
  * @param integer $columnIndex          Returns the indicated 0-indexed column when the value of $fetchStyle is
  *                                      Doctrine_Core::FETCH_COLUMN. Defaults to 0.
  *
  * @return array
  */
 public function fetchAll($fetchStyle = Doctrine_Core::FETCH_BOTH, $colnum = 0)
 {
     return $this->connection->fetchArray($this->result, $fetchStyle);
 }
开发者ID:dator,项目名称:doctrine1-drak,代码行数:16,代码来源:Jdbcbridge.php

示例9: nextRecord

 public function nextRecord()
 {
     if ($data = $this->handle->fetchArray(SQLITE3_ASSOC)) {
         return $data;
     } else {
         return false;
     }
 }
开发者ID:rodneyway,项目名称:ss3-misc,代码行数:8,代码来源:SQLite3Database.php


注:本文中的resource::fetchArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。