本文整理匯總了PHP中Drupal\Core\Database\Connection::queryTemporary方法的典型用法代碼示例。如果您正苦於以下問題:PHP Connection::queryTemporary方法的具體用法?PHP Connection::queryTemporary怎麽用?PHP Connection::queryTemporary使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Drupal\Core\Database\Connection
的用法示例。
在下文中一共展示了Connection::queryTemporary方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getTemporaryResultsTable
/**
* Creates a temporary table from a select query.
*
* Will return the name of a table containing the item IDs of all results, or
* FALSE on failure.
*
* @param \Drupal\Core\Database\Query\SelectInterface $db_query
* The select query whose results should be stored in the temporary table.
*
* @return string|false
* The name of the temporary table, or FALSE on failure.
*/
protected function getTemporaryResultsTable(SelectInterface $db_query)
{
// We only need the id field, not the score.
$fields =& $db_query->getFields();
unset($fields['score']);
if (count($fields) != 1 || !isset($fields['item_id'])) {
$this->getLogger()->warning('Error while adding facets: only "item_id" field should be used, used are: @fields.', array('@fields' => implode(', ', array_keys($fields))));
return FALSE;
}
$expressions =& $db_query->getExpressions();
$expressions = array();
// If there's a GROUP BY for item_id, we leave that, all others need to be
// discarded.
$group_by =& $db_query->getGroupBy();
$group_by = array_intersect_key($group_by, array('t.item_id' => TRUE));
$db_query->distinct();
if (!$db_query->preExecute()) {
return FALSE;
}
$args = $db_query->getArguments();
try {
$result = $this->database->queryTemporary((string) $db_query, $args);
} catch (\PDOException $e) {
watchdog_exception('search_api', $e, '%type while trying to create a temporary table: @message in %function (line %line of %file).');
return FALSE;
}
return $result;
}
示例2: getTemporaryResultsTable
/**
* Creates a temporary table from a select query.
*
* Will return the name of a table containing the item IDs of all results, or
* FALSE on failure.
*
* @param \Drupal\Core\Database\Query\SelectInterface $db_query
* The select query whose results should be stored in the temporary table.
*
* @return string|false
* The name of the temporary table, or FALSE on failure.
*/
protected function getTemporaryResultsTable(SelectInterface $db_query) {
// We only need the id field, not the score.
$fields = &$db_query->getFields();
unset($fields['score']);
if (count($fields) != 1 || !isset($fields['item_id'])) {
$this->getLogger()->warning('Error while adding facets: only "item_id" field should be used, used are: @fields.', array('@fields' => implode(', ', array_keys($fields))));
return FALSE;
}
$expressions = &$db_query->getExpressions();
$expressions = array();
$db_query->distinct();
if (!$db_query->preExecute()) {
return FALSE;
}
$args = $db_query->getArguments();
return $this->database->queryTemporary((string) $db_query, $args);
}