1.20.x views_plugin_query_default.inc | views_plugin_query_default::database_connection() |
Return the database connection that will be used for the query.
Return value
A DatabaseConnection object.:
File
- modules/
views/ plugins/ views_plugin_query_default.inc, line 1252 - Defines the default query object.
Class
- views_plugin_query_default
- Object used to create a SELECT query.
Code
function database_connection() {
$target = 'default';
$key = 'default';
// Detect an external database and set the
if (isset($this->view->base_database)) {
$key = $this->view->base_database;
}
// Set the slave target if the slave option is set
if (!empty($this->options['slave'])) {
$target = 'slave';
}
$database_connection = Database::getConnection($target, $key);
$database_connection->setSessionTimezoneOffset('+00:00');
return $database_connection;
}