function db_select in Drupal 8
Same name and namespace in other branches
- 7 includes/database/database.inc \db_select()
Returns a new SelectQuery object for the active database.
Parameters
string|\Drupal\Core\Database\Query\SelectInterface $table: The base table for this query. May be a string or another SelectInterface object. If a SelectInterface object is passed, it will be used as a subselect.
string $alias: (optional) The alias for the base table of this query.
array $options: (optional) An array of options to control how the query operates.
Return value
\Drupal\Core\Database\Query\Select A new Select object for this connection.
Deprecated
in drupal:8.0.0 and is removed from drupal:9.0.0. Instead, get a database connection injected into your service from the container and call select() on it. For example, $injected_database->select($table, $alias, $options);
See also
https://www.drupal.org/node/2993033
\Drupal\Core\Database\Connection::select()
\Drupal\Core\Database\Connection::defaultOptions()
Related topics
1 call to db_select()
- DatabaseLegacyTest::testDbSelect in core/
tests/ Drupal/ KernelTests/ Core/ Database/ DatabaseLegacyTest.php - Tests the db_select() function.
File
- core/
includes/ database.inc, line 281 - Core systems for the database layer.
Code
function db_select($table, $alias = NULL, array $options = []) {
@trigger_error('db_select() is deprecated in drupal:8.0.0. It will be removed from drupal:9.0.0. Instead, get a database connection injected into your service from the container and call select() on it. For example, $injected_database->db_select($table, $alias, $options). See https://www.drupal.org/node/2993033', E_USER_DEPRECATED);
return Database::getConnection(_db_get_target($options))
->select($table, $alias, $options);
}