本文整理汇总了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);
}