You are here

private function SQLite3Cache::findById in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/doctrine/cache/lib/Doctrine/Common/Cache/SQLite3Cache.php \Doctrine\Common\Cache\SQLite3Cache::findById()

Find a single row by ID.

Parameters

mixed $id:

boolean $includeData:

Return value

array|null

2 calls to SQLite3Cache::findById()
SQLite3Cache::doContains in vendor/doctrine/cache/lib/Doctrine/Common/Cache/SQLite3Cache.php
Tests if an entry exists in the cache.
SQLite3Cache::doFetch in vendor/doctrine/cache/lib/Doctrine/Common/Cache/SQLite3Cache.php
Fetches an entry from the cache.

File

vendor/doctrine/cache/lib/Doctrine/Common/Cache/SQLite3Cache.php, line 164

Class

SQLite3Cache
SQLite3 cache provider.

Namespace

Doctrine\Common\Cache

Code

private function findById($id, $includeData = true) {
  list($idField) = $fields = $this
    ->getFields();
  if (!$includeData) {
    $key = array_search(static::DATA_FIELD, $fields);
    unset($fields[$key]);
  }
  $statement = $this->sqlite
    ->prepare(sprintf('SELECT %s FROM %s WHERE %s = :id LIMIT 1', implode(',', $fields), $this->table, $idField));
  $statement
    ->bindValue(':id', $id, SQLITE3_TEXT);
  $item = $statement
    ->execute()
    ->fetchArray(SQLITE3_ASSOC);
  if ($item === false) {
    return null;
  }
  if ($this
    ->isExpired($item)) {
    $this
      ->doDelete($id);
    return null;
  }
  return $item;
}