本文整理匯總了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;
}
示例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);
}
}
示例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;
}
示例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);
}