db_next_id

db_next_id($existing_id = 0) Retrieves a unique id. Use this function if for some reason you can't use a serial field. Using a serial field is preferred, and InsertQuery::execute() returns the value of the last ID inserted. Parameters int $existing_id: After a database import, it might be that the sequences table is behind, so by passing in a minimum ID, it can be assured that we never issue the same ID. Return value int An integer number larger than any number returned before for this sequen

db_merge

db_merge($table, array $options = array()) Returns a new MergeQuery object for the active database. Parameters string $table: Name of the table to associate with this query. array $options: An array of options to control how the query operates. Return value \Drupal\Core\Database\Query\Merge A new Merge object for this connection. Deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get a database connection injected into your service from the container and call merge() o

db_like

db_like($string) Escapes characters that work as wildcard characters in a LIKE pattern. The wildcard characters "%" and "_" as well as backslash are prefixed with a backslash. Use this to do a search for a verbatim string without any wildcard behavior. You must use a query builder like db_select() in order to use db_like() on all supported database systems. Using db_like() with db_query() or db_query_range() is not supported. For example, the following does a case-insensitive query for all rows

db_installer_object

db_installer_object($driver) Returns a database installer object. Parameters $driver: The name of the driver. Return value \Drupal\Core\Database\Install\Tasks A class defining the requirements and tasks for installing the database. File core/includes/install.inc, line 1100 API functions for installing modules and themes. Code function db_installer_object($driver) { // We cannot use Database::getConnection->getDriverClass() here, because // the connection object is not yet functional.

db_insert

db_insert($table, array $options = array()) Returns a new InsertQuery object for the active database. Parameters string $table: The table into which to insert. array $options: An array of options to control how the query operates. Return value \Drupal\Core\Database\Query\Insert A new Insert object for this connection. Deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get a database connection injected into your service from the container and call insert() on it. For e

db_index_exists

db_index_exists($table, $name) Checks if an index exists in the given table. Parameters string $table: The name of the table in drupal (no prefixing). string $name: The name of the index in drupal (no prefixing). Return value bool TRUE if the given index exists, otherwise FALSE. Deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get a database connection injected into your service from the container, get its schema driver, and call indexExists() on it. For example, $in

db_ignore_replica

db_ignore_replica() Sets a session variable specifying the lag time for ignoring a replica server (A replica server is traditionally referred to as a "slave" in database server documentation). See also https://www.drupal.org/node/2275877 File core/includes/database.inc, line 1037 Core systems for the database layer. Code function db_ignore_replica() { $connection_info = Database::getConnectionInfo(); // Only set ignore_replica_server if there are replica servers being used, // which is

db_find_tables

db_find_tables($table_expression) Finds all tables that are like the specified base table name. Parameters string $table_expression: An SQL expression, for example "simpletest%" (without the quotes). Return value array Array, both the keys and the values are the matching tables. Deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get a database connection injected into your service from the container, get its schema driver, and call findTables() on it. For example, $inj

db_field_set_no_default

db_field_set_no_default($table, $field) Sets a field to have no default value. Parameters $table: The table to be altered. $field: The field to be altered. Deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get a database connection injected into your service from the container, get its schema driver, and call fieldSetNoDefault() on it. For example, $injected_database->schema()->fieldSetNoDefault($table, $field); See also \Drupal\Core\Database\Schema::fieldSetNo

db_field_set_default

db_field_set_default($table, $field, $default) Sets the default value for a field. Parameters $table: The table to be altered. $field: The field to be altered. $default: Default value to be set. NULL for 'default NULL'. Deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get a database connection injected into your service from the container, get its schema driver, and call fieldSetDefault() on it. For example, $injected_database->schema()->fieldSetDefault($table,