本文整理汇总了PHP中Drupal\Core\Database\Connection::escapeTable方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::escapeTable方法的具体用法?PHP Connection::escapeTable怎么用?PHP Connection::escapeTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Database\Connection
的用法示例。
在下文中一共展示了Connection::escapeTable方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMultiple
/**
* 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: getAllCollectionNames
/**
* {@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: getAll
/**
* 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: getRoutesByPath
/**
* 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: getRoutesCount
/**
* {@inheritdoc}
*/
public function getRoutesCount()
{
return $this->connection->query("SELECT COUNT(*) FROM {" . $this->connection->escapeTable($this->tableName) . "}")->fetchField();
}
示例6: escapeTable
/**
* {@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: escapeTable
/**
* {@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: __construct
/**
* 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: escapeTable
/**
* {@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;
}