コード例 #1
0
 /**
  * Implements Drupal\Core\Cache\CacheBackendInterface::getMultiple().
  */
 public function getMultiple(&$cids, $allow_invalid = FALSE)
 {
     $cid_mapping = array();
     foreach ($cids as $cid) {
         $cid_mapping[$this->normalizeCid($cid)] = $cid;
     }
     // When serving cached pages, the overhead of using ::select() was found
     // to add around 30% overhead to the request. Since $this->bin is a
     // variable, this means the call to ::query() here uses a concatenated
     // string. This is highly discouraged under any other circumstances, and
     // is used here only due to the performance overhead we would incur
     // otherwise. When serving an uncached page, the overhead of using
     // ::select() is a much smaller proportion of the request.
     $result = array();
     try {
         $result = $this->connection->query('SELECT cid, data, created, expire, serialized, tags, checksum_invalidations, checksum_deletions FROM {' . $this->connection->escapeTable($this->bin) . '} WHERE cid IN (:cids)', array(':cids' => array_keys($cid_mapping)));
     } catch (\Exception $e) {
         // Nothing to do.
     }
     $cache = array();
     foreach ($result as $item) {
         // Map the cache ID back to the original.
         $item->cid = $cid_mapping[$item->cid];
         $item = $this->prepareItem($item, $allow_invalid);
         if ($item) {
             $cache[$item->cid] = $item;
         }
     }
     $cids = array_diff($cids, array_keys($cache));
     return $cache;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function getAllCollectionNames()
 {
     try {
         return $this->connection->query('SELECT DISTINCT collection FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection <> :collection ORDER by collection', array(':collection' => StorageInterface::DEFAULT_COLLECTION))->fetchCol();
     } catch (\Exception $e) {
         return array();
     }
 }
コード例 #3
0
 /**
  * Implements Drupal\Core\KeyValueStore\KeyValueStoreInterface::getAll().
  */
 public function getAll()
 {
     $result = $this->connection->query('SELECT name, value FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection', array(':collection' => $this->collection));
     $values = array();
     foreach ($result as $item) {
         if ($item) {
             $values[$item->name] = $this->serializer->decode($item->value);
         }
     }
     return $values;
 }
コード例 #4
0
 /**
  * Get all routes which match a certain pattern.
  *
  * @param string $path
  *   The route pattern to search for (contains % as placeholders).
  *
  * @return \Symfony\Component\Routing\RouteCollection
  *   Returns a route collection of matching routes.
  */
 protected function getRoutesByPath($path)
 {
     // Filter out each empty value, though allow '0' and 0, which would be
     // filtered out by empty().
     $parts = array_values(array_filter(explode('/', $path), function ($value) {
         return $value !== NULL && $value !== '';
     }));
     $collection = new RouteCollection();
     $ancestors = $this->getCandidateOutlines($parts);
     if (empty($ancestors)) {
         return $collection;
     }
     $routes = $this->connection->query("SELECT name, route FROM {" . $this->connection->escapeTable($this->tableName) . "} WHERE pattern_outline IN (:patterns) ORDER BY fit DESC, name ASC", array(':patterns' => $ancestors))->fetchAllKeyed();
     foreach ($routes as $name => $route) {
         $route = unserialize($route);
         if (preg_match($route->compile()->getRegex(), $path, $matches)) {
             $collection->add($name, $route);
         }
     }
     return $collection;
 }
コード例 #5
0
ファイル: RouteProvider.php プロジェクト: papillon-cendre/d8
 /**
  * {@inheritdoc}
  */
 public function getRoutesCount()
 {
     return $this->connection->query("SELECT COUNT(*) FROM {" . $this->connection->escapeTable($this->tableName) . "}")->fetchField();
 }
コード例 #6
0
ファイル: Connection.php プロジェクト: Nikola-xiii/d8intranet
 /**
  * {@inheritdoc}
  */
 public function escapeTable($table)
 {
     $escaped = parent::escapeTable($table);
     // Quote identifier to make it case-sensitive.
     if (preg_match('/[A-Z]/', $escaped)) {
         $escaped = '"' . $escaped . '"';
     }
     return $escaped;
 }
コード例 #7
0
ファイル: Connection.php プロジェクト: papillon-cendre/d8
 /**
  * {@inheritdoc}
  */
 public function escapeTable($table)
 {
     $escaped = parent::escapeTable($table);
     // Quote identifier to make it case-sensitive.
     if (preg_match('/[A-Z]/', $escaped)) {
         $escaped = '"' . $escaped . '"';
     } elseif (in_array(strtolower($escaped), $this->postgresqlReservedKeyWords)) {
         // Quote the table name for PostgreSQL reserved key words.
         $escaped = '"' . $escaped . '"';
     }
     return $escaped;
 }
コード例 #8
0
ファイル: Subscription.php プロジェクト: alnutile/drunatra
 /**
  * Constructs a Subscription object.
  *
  * @param \Drupal\Core\Database\Connection $connection
  *   The database connection object.
  * @param string $table
  *   The database table to perform queries on.
  */
 public function __construct(Connection $connection, $table)
 {
     $this->connection = $connection;
     $this->table = $table;
     $this->tableEscaped = $connection->escapeTable($this->table);
 }
コード例 #9
0
ファイル: Connection.php プロジェクト: eigentor/tommiblog
 /**
  * {@inheritdoc}
  */
 public function escapeTable($table)
 {
     $escaped = parent::escapeTable($table);
     // Ensure that each part (database, schema and table) of the table name is
     // properly and independently escaped.
     $parts = explode('.', $escaped);
     $parts = array_map([$this, 'doEscape'], $parts);
     $escaped = implode('.', $parts);
     return $escaped;
 }