Drupal 8  8.0.2
Connection Class Reference
Inheritance diagram for Connection:

Public Member Functions

 __construct (\PDO $connection, array $connection_options)
 
 destroy ()
 
 getConnectionOptions ()
 
 prefixTables ($sql)
 
 tablePrefix ($table= 'default')
 
 getUnprefixedTablesMap ()
 
 getFullQualifiedTableName ($table)
 
 prepareQuery ($query)
 
 setTarget ($target=NULL)
 
 getTarget ()
 
 setKey ($key)
 
 getKey ()
 
 setLogger (Log $logger)
 
 getLogger ()
 
 makeSequenceName ($table, $field)
 
 makeComment ($comments)
 
 query ($query, array $args=array(), $options=array())
 
 getDriverClass ($class)
 
 select ($table, $alias=NULL, array $options=array())
 
 insert ($table, array $options=array())
 
 merge ($table, array $options=array())
 
 upsert ($table, array $options=array())
 
 update ($table, array $options=array())
 
 delete ($table, array $options=array())
 
 truncate ($table, array $options=array())
 
 schema ()
 
 escapeDatabase ($database)
 
 escapeTable ($table)
 
 escapeField ($field)
 
 escapeAlias ($field)
 
 escapeLike ($string)
 
 inTransaction ()
 
 transactionDepth ()
 
 startTransaction ($name= '')
 
 rollback ($savepoint_name= 'drupal_transaction')
 
 pushTransaction ($name)
 
 popTransaction ($name)
 
 queryRange ($query, $from, $count, array $args=array(), array $options=array())
 
 queryTemporary ($query, array $args=array(), array $options=array())
 
 driver ()
 
 version ()
 
 clientVersion ()
 
 supportsTransactions ()
 
 supportsTransactionalDDL ()
 
 databaseType ()
 
 createDatabase ($database)
 
 mapConditionOperator ($operator)
 
 commit ()
 
 nextId ($existing_id=0)
 
 prepare ($statement, array $driver_options=array())
 
 quote ($string, $parameter_type=\PDO::PARAM_STR)
 
 __sleep ()
 

Static Public Member Functions

static open (array &$connection_options=array())
 

Protected Member Functions

 defaultOptions ()
 
 setPrefix ($prefix)
 
 filterComment ($comment= '')
 
 handleQueryException (\PDOException $e, $query, array $args=array(), $options=array())
 
 expandArguments (&$query, &$args)
 
 popCommittableTransactions ()
 
 generateTemporaryTableName ()
 

Protected Attributes

 $target = NULL
 
 $key = NULL
 
 $logger = NULL
 
 $transactionLayers = array()
 
 $driverClasses = array()
 
 $statementClass = 'Drupal\Core\Database\Statement'
 
 $transactionSupport = TRUE
 
 $transactionalDDLSupport = FALSE
 
 $temporaryNameIndex = 0
 
 $connection
 
 $connectionOptions = array()
 
 $schema = NULL
 
 $prefixes = array()
 
 $prefixSearch = array()
 
 $prefixReplace = array()
 
 $unprefixedTablesMap = []
 

Detailed Description

Base Database API class.

This class provides a Drupal-specific extension of the PDO database abstraction class in PHP. Every database driver implementation must provide a concrete implementation of it to support special handling required by that database.

See Also
http://php.net/manual/book.pdo.php

Constructor & Destructor Documentation

__construct ( \PDO  $connection,
array  $connection_options 
)

Constructs a Connection object.

Parameters
\PDO$connectionAn object of the PDO class representing a database connection.
array$connection_optionsAn array of options for the connection. May include the following:
  • prefix
  • namespace
  • Other driver-specific options.

References Connection\setPrefix().

Here is the call graph for this function:

Member Function Documentation

__sleep ( )

Prevents the database connection from being serialized.

clientVersion ( )

Returns the version of the database client.

commit ( )

Throws an exception to deny direct access to transaction commits.

We do not want to allow users to commit transactions at any time, only by destroying the transaction object or allowing it to go out of scope. A direct commit bypasses all of the safety checks we've built on top of PDO's transaction routines.

Exceptions
\Drupal\Core\Database\TransactionExplicitCommitNotAllowedException
See Also
createDatabase (   $database)
abstract

Creates a database.

In order to use this method, you must be connected without a database specified.

Parameters
string$databaseThe name of the database to create.
databaseType ( )
abstract

Returns the name of the PDO driver for this connection.

Referenced by DbDumpCommand\getTableSchema().

Here is the caller graph for this function:

defaultOptions ( )
protected

Returns the default query options for any given query.

A given query can be customized with a number of option flags in an associative array:

  • target: The database "target" against which to execute a query. Valid values are "default" or "replica". The system will first try to open a connection to a database specified with the user-supplied key. If one is not available, it will silently fall back to the "default" target. If multiple databases connections are specified with the same target, one will be selected at random for the duration of the request.
  • fetch: This element controls how rows from a result set will be returned. Legal values include PDO::FETCH_ASSOC, PDO::FETCH_BOTH, PDO::FETCH_OBJ, PDO::FETCH_NUM, or a string representing the name of a class. If a string is specified, each record will be fetched into a new object of that class. The behavior of all other values is defined by PDO. See http://php.net/manual/pdostatement.fetch.php
  • return: Depending on the type of query, different return values may be meaningful. This directive instructs the system which type of return value is desired. The system will generally set the correct value automatically, so it is extremely rare that a module developer will ever need to specify this value. Setting it incorrectly will likely lead to unpredictable results or fatal errors. Legal values include:
    • Database::RETURN_STATEMENT: Return the prepared statement object for the query. This is usually only meaningful for SELECT queries, where the statement object is how one accesses the result set returned by the query.
    • Database::RETURN_AFFECTED: Return the number of rows affected by an UPDATE or DELETE query. Be aware that means the number of rows actually changed, not the number of rows matched by the WHERE clause.
    • Database::RETURN_INSERT_ID: Return the sequence ID (primary key) created by an INSERT statement on a table that contains a serial column.
    • Database::RETURN_NULL: Do not return anything, as there is no meaningful value to return. That is the case for INSERT queries on tables that do not contain a serial column.
  • throw_exception: By default, the database system will catch any errors on a query as an Exception, log it, and then rethrow it so that code further up the call chain can take an appropriate action. To suppress that behavior and simply return NULL on failure, set this option to FALSE.
  • allow_delimiter_in_query: By default, queries which have the ; delimiter any place in them will cause an exception. This reduces the chance of SQL injection attacks that terminate the original query and add one or more additional queries (such as inserting new user accounts). In rare cases, such as creating an SQL function, a ; is needed and can be allowed by changing this option to TRUE.
Returns
array An array of default query options.

References Database\RETURN_STATEMENT.

Referenced by Connection\query().

Here is the caller graph for this function:

delete (   $table,
array  $options = array() 
)

Prepares and returns a DELETE query object.

Parameters
string$tableThe table to use for the delete statement.
array$options(optional) An array of options on the query.
Returns
A new Delete query object.
See Also

References Connection\getDriverClass().

Here is the call graph for this function:

destroy ( )

Destroys this Connection object.

PHP does not destruct an object if it is still referenced in other variables. In case of PDO database connection objects, PHP only closes the connection when the PDO object is destructed, so any references to this object may cause the number of maximum allowed connections to be exceeded.

References Connection\schema().

Here is the call graph for this function:

driver ( )
abstract

Returns the type of database driver.

This is not necessarily the same as the type of the database itself. For instance, there could be two MySQL drivers, mysql and mysql_mock. This function would return different values for each, but both would return "mysql" for databaseType().

Returns
string The type of database driver.

Referenced by Connection\getDriverClass().

Here is the caller graph for this function:

escapeAlias (   $field)

Escapes an alias name string.

Force all alias names to be strictly alphanumeric-plus-underscore. In contrast to DatabaseConnection::escapeField() / DatabaseConnection::escapeTable(), this doesn't allow the period (".") because that is not allowed in aliases.

Parameters
string$fieldAn unsanitized alias name.
Returns
string The sanitized alias name.
escapeDatabase (   $database)

Escapes a database name string.

Force all database names to be strictly alphanumeric-plus-underscore. For some database drivers, it may also wrap the database name in database-specific escape characters.

Parameters
string$databaseAn unsanitized database name.
Returns
string The sanitized database name.
escapeField (   $field)

Escapes a field name string.

Force all field names to be strictly alphanumeric-plus-underscore. For some database drivers, it may also wrap the field name in database-specific escape characters.

Parameters
string$fieldAn unsanitized field name.
Returns
string The sanitized field name.

Referenced by Condition\compile().

Here is the caller graph for this function:

escapeLike (   $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.

For example, the following does a case-insensitive query for all rows whose name starts with $prefix:

$result = db_query(
'SELECT * FROM person WHERE name LIKE :pattern',
array(':pattern' => db_like($prefix) . '%')
);

Backslash is defined as escape character for LIKE patterns in Drupal::mapConditionOperator().

Parameters
string$stringThe string to escape.
Returns
string The escaped string.
escapeTable (   $table)

Escapes a table name string.

Force all table names to be strictly alphanumeric-plus-underscore. For some database drivers, it may also wrap the table name in database-specific escape characters.

Parameters
string$tableAn unsanitized table name.
Returns
string The sanitized table name.
expandArguments ( $query,
$args 
)
protected

Expands out shorthand placeholders.

Drupal supports an alternate syntax for doing arrays of values. We therefore need to expand them out into a full, executable query string.

Parameters
string$queryThe query string to modify.
array$argsThe arguments for the query.
Returns
bool TRUE if the query was modified, FALSE otherwise.
Exceptions
\InvalidArgumentExceptionThis exception is thrown when:
  • A placeholder that ends in [] is supplied, and the supplied value is not an array.
  • A placeholder that does not end in [] is supplied, and the supplied value is an array.

Referenced by Connection\query().

Here is the caller graph for this function:

filterComment (   $comment = '')
protected

Sanitize a query comment string.

Ensure a query comment does not include strings such as "* /" that might terminate the comment early. This avoids SQL injection attacks via the query comment. The comment strings in this example are separated by a space to avoid PHP parse errors.

For example, the comment:

db_update('example')
->condition('id', $id)
->fields(array('field2' => 10))
->comment('Exploit * / DROP TABLE node; --')
->execute()

Would result in the following SQL statement being generated:

"/ * Exploit * / DROP TABLE node. -- * / UPDATE example SET field2=..."

Unless the comment is sanitised first, the SQL server would drop the node table and ignore the rest of the SQL statement.

Parameters
string$commentA query comment string.
Returns
string A sanitized version of the query comment string.

Referenced by Connection\makeComment().

Here is the caller graph for this function:

generateTemporaryTableName ( )
protected

Generates a temporary table name.

Returns
string A table name.
getConnectionOptions ( )

Returns the connection information for this connection object.

Note that Database::getConnectionInfo() is for requesting information about an arbitrary database connection that is defined. This method is for requesting the connection information of this specific open connection object.

Returns
array An array of the connection information. The exact list of properties is driver-dependent.

Referenced by DbDumpCommand\getFieldOrder(), and Connection\getFullQualifiedTableName().

Here is the caller graph for this function:

getDriverClass (   $class)

Gets the driver-specific override class if any for the specified class.

Parameters
string$classThe class for which we want the potentially driver-specific class.
Returns
string The name of the class that should be used for this driver.

References Connection\driver().

Referenced by Connection\delete(), Connection\insert(), Connection\merge(), Connection\schema(), Connection\select(), Connection\startTransaction(), Connection\truncate(), Connection\update(), and Connection\upsert().

Here is the call graph for this function:

Here is the caller graph for this function:

getFullQualifiedTableName (   $table)

Get a fully qualified table name.

Parameters
string$tableThe name of the table in question.
Returns
string

References Connection\getConnectionOptions(), and Connection\tablePrefix().

Here is the call graph for this function:

getKey ( )

Returns the key this connection is associated with.

Returns
string|null The key of this connection, or NULL if no key is set.

Referenced by Query\__construct(), and DbImportCommand\runScript().

Here is the caller graph for this function:

getLogger ( )

Gets the current logging object for this connection.

Returns
|null The current logging object for this connection. If there isn't one, NULL is returned.
getTarget ( )

Returns the target this connection is associated with.

Returns
string|null The target string of this connection, or NULL if no target is set.
getUnprefixedTablesMap ( )

Gets a list of individually prefixed table names.

Returns
array An array of un-prefixed table names, keyed by their fully qualified table names (i.e. prefix + table_name).
handleQueryException ( \PDOException  $e,
  $query,
array  $args = array(),
  $options = array() 
)
protected

Wraps and re-throws any PDO exception thrown by static::query().

Parameters
\PDOException$eThe exception thrown by static::query().
$queryThe query executed by static::query().
array$argsAn array of arguments for the prepared statement.
array$optionsAn associative array of options to control how the query is run.
Returns
|int|null Most database drivers will return NULL when a PDO exception is thrown for a query, but some of them may need to re-run the query, so they can also return a object or an integer.
Exceptions
\Drupal\Core\Database\DatabaseExceptionWrapper
\Drupal\Core\Database\IntegrityConstraintViolationException

Referenced by Connection\query().

Here is the caller graph for this function:

insert (   $table,
array  $options = array() 
)

Prepares and returns an INSERT query object.

Parameters
string$tableThe table to use for the insert statement.
array$options(optional) An array of options on the query.
Returns
A new Insert query object.
See Also

References Connection\getDriverClass().

Here is the call graph for this function:

inTransaction ( )

Determines if there is an active transaction open.

Returns
bool TRUE if we're currently in a transaction, FALSE otherwise.

References Connection\transactionDepth().

Referenced by Connection\addSavepoint(), Connection\pushTransaction(), and Connection\rollback().

Here is the call graph for this function:

Here is the caller graph for this function:

makeComment (   $comments)

Flatten an array of query comments into a single comment string.

The comment string will be sanitized to avoid SQL injection attacks.

Parameters
string[]$comments An array of query comment strings.
Returns
string A sanitized comment string.

References Connection\filterComment().

Here is the call graph for this function:

makeSequenceName (   $table,
  $field 
)

Creates the appropriate sequence name for a given table and serial field.

This information is exposed to all database drivers, although it is only useful on some of them. This method is table prefix-aware.

Parameters
string$tableThe table name to use for the sequence.
string$fieldThe field name to use for the sequence.
Returns
string A table prefix-parsed string for the sequence name.

References Connection\prefixTables().

Referenced by Connection\nextId().

Here is the call graph for this function:

Here is the caller graph for this function:

mapConditionOperator (   $operator)
abstract

Gets any special processing requirements for the condition operator.

Some condition types require special processing, such as IN, because the value data they pass in is not a simple value. This is a simple overridable lookup function. Database connections should define only those operators they wish to be handled differently than the default.

Parameters
string$operatorThe condition operator, such as "IN", "BETWEEN", etc. Case-sensitive.
Returns
The extra handling directives for the specified operator, or NULL.
See Also
::compile()

Referenced by Condition\compile().

Here is the caller graph for this function:

merge (   $table,
array  $options = array() 
)

Prepares and returns a MERGE query object.

Parameters
string$tableThe table to use for the merge statement.
array$options(optional) An array of options on the query.
Returns
A new Merge query object.
See Also

References Connection\getDriverClass().

Here is the call graph for this function:

nextId (   $existing_id = 0)
abstract

Retrieves an unique ID from a given sequence.

Use this function if for some reason you can't use a serial field. For example, MySQL has no ways of reading of the current value of a sequence and PostgreSQL can not advance the sequence to be larger than a given value. Or sometimes you just need a unique integer.

Parameters
$existing_id(optional) After a database import, it might be that the sequences table is behind, so by passing in the maximum existing ID, it can be assured that we never issue the same ID.
Returns
An integer number larger than any number returned by earlier calls and also larger than the $existing_id if one was passed in.
static open ( array &  $connection_options = array())
static

Opens a PDO connection.

Parameters
array$connection_optionsThe database connection settings array.
Returns
A object.

Referenced by MigrateTestCase\getDatabase(), and MigrateSqlIdMapTest\testGetQualifiedMapTablePrefix().

Here is the caller graph for this function:

popCommittableTransactions ( )
protected

Internal function: commit all the transaction layers that can commit.

References Connection\query().

Referenced by Connection\popTransaction(), and Connection\rollback().

Here is the call graph for this function:

Here is the caller graph for this function:

popTransaction (   $name)

Decreases the depth of transaction nesting.

If we pop off the last transaction layer, then we either commit or roll back the transaction as necessary. If no transaction is active, we return because the transaction may have manually been rolled back.

Parameters
string$nameThe name of the savepoint.
Exceptions
\Drupal\Core\Database\TransactionNoActiveException
\Drupal\Core\Database\TransactionCommitFailedException
See Also

References Connection\popCommittableTransactions(), and Connection\supportsTransactions().

Referenced by Connection\releaseSavepoint().

Here is the call graph for this function:

Here is the caller graph for this function:

prefixTables (   $sql)

Appends a database prefix to all tables in a query.

Queries sent to Drupal should wrap all table names in curly brackets. This function searches for this syntax and adds Drupal's table prefix to all tables, allowing Drupal to coexist with other systems in the same database and/or schema if necessary.

Parameters
string$sqlA string containing a partial or entire SQL query.
Returns
string The properly-prefixed string.

Referenced by Connection\makeSequenceName(), and Connection\prepareQuery().

Here is the caller graph for this function:

prepare (   $statement,
array  $driver_options = array() 
)

Prepares a statement for execution and returns a statement object

Emulated prepared statements does not communicate with the database server so this method does not check the statement.

Parameters
string$statementThis must be a valid SQL statement for the target database server.
array$driver_options(optional) This array holds one or more key=>value pairs to set attribute values for the PDOStatement object that this method returns. You would most commonly use this to set the ::ATTR_CURSOR value to ::CURSOR_SCROLL to request a scrollable cursor. Some drivers have driver specific options that may be set at prepare-time. Defaults to an empty array.
Returns
|false If the database server successfully prepares the statement, returns a object. If the database server cannot successfully prepare the statement returns FALSE or emits (depending on error handling).
Exceptions
\PDOException
See Also
::prepare()
prepareQuery (   $query)

Prepares a query string and returns the prepared statement.

This method caches prepared statements, reusing them when possible. It also prefixes tables names enclosed in curly-braces.

Parameters
$queryThe query string as SQL, with curly-braces surrounding the table names.
Returns
A PDO prepared statement ready for its execute() method.

References Connection\prefixTables().

Referenced by Connection\query().

Here is the call graph for this function:

Here is the caller graph for this function:

pushTransaction (   $name)

Increases the depth of transaction nesting.

If no transaction is already active, we begin a new transaction.

Parameters
string$nameThe name of the transaction.
Exceptions
\Drupal\Core\Database\TransactionNameNonUniqueException
See Also

References Connection\inTransaction(), Connection\query(), and Connection\supportsTransactions().

Referenced by Connection\addSavepoint().

Here is the call graph for this function:

Here is the caller graph for this function:

query (   $query,
array  $args = array(),
  $options = array() 
)

Executes a query string against the database.

This method provides a central handler for the actual execution of every query. All queries executed by Drupal are executed as PDO prepared statements.

Parameters
string | \Drupal\Core\Database\StatementInterface$queryThe query to execute. In most cases this will be a string containing an SQL query with placeholders. An already-prepared instance of StatementInterface may also be passed in order to allow calling code to manually bind variables to a query. If a StatementInterface is passed, the $args array will be ignored. It is extremely rare that module code will need to pass a statement object to this method. It is used primarily for database drivers for databases that require special LOB field handling.
array$argsAn array of arguments for the prepared statement. If the prepared statement uses ? placeholders, this array must be an indexed array. If it contains named placeholders, it must be an associative array.
array$optionsAn associative array of options to control how the query is run. The given options will be merged with self::defaultOptions(). See the documentation for self::defaultOptions() for details. Typically, $options['return'] will be set by a default or by a query builder, and should not be set by a user.
Returns
|int|null This method will return one of the following:
  • If either $options['return'] === self::RETURN_STATEMENT, or $options['return'] is not set (due to self::defaultOptions()), returns the executed statement.
  • If $options['return'] === self::RETURN_AFFECTED, returns the number of rows affected by the query (not the number matched).
  • If $options['return'] === self::RETURN_INSERT_ID, returns the generated insert ID of the last query.
  • If either $options['return'] === self::RETURN_NULL, or an exception occurs and $options['throw_exception'] evaluates to FALSE, returns NULL.
Exceptions
\Drupal\Core\Database\DatabaseExceptionWrapper
\Drupal\Core\Database\IntegrityConstraintViolationException
\InvalidArgumentException
See Also
::defaultOptions()

References Connection\defaultOptions(), Connection\expandArguments(), Connection\handleQueryException(), Connection\prepareQuery(), Database\RETURN_AFFECTED, Database\RETURN_INSERT_ID, Database\RETURN_NULL, and Database\RETURN_STATEMENT.

Referenced by Connection\__construct(), Connection\__destruct(), DbDumpCommand\getFieldOrder(), DbDumpCommand\getTableCollation(), DbDumpCommand\getTableData(), DbDumpCommand\getTableIndexes(), DbDumpCommand\getTableSchema(), Connection\handleQueryException(), Connection\popCommittableTransactions(), Connection\pushTransaction(), and Connection\rollback().

Here is the call graph for this function:

Here is the caller graph for this function:

queryRange (   $query,
  $from,
  $count,
array  $args = array(),
array  $options = array() 
)
abstract

Runs a limited-range query on this database object.

Use this as a substitute for ->query() when a subset of the query is to be returned. User-supplied arguments to the query should be passed in as separate parameters so that they can be properly escaped to avoid SQL injection attacks.

Parameters
string$queryA string containing an SQL query.
int$fromThe first result row to return.
int$countThe maximum number of result rows to return.
array$args(optional) An array of values to substitute into the query at placeholder markers.
array$options(optional) An array of options on the query.
Returns
A database query result resource, or NULL if the query was not executed correctly.
queryTemporary (   $query,
array  $args = array(),
array  $options = array() 
)
abstract

Runs a SELECT query and stores its results in a temporary table.

Use this as a substitute for ->query() when the results need to stored in a temporary table. Temporary tables exist for the duration of the page request. User-supplied arguments to the query should be passed in as separate parameters so that they can be properly escaped to avoid SQL injection attacks.

Note that if you need to know how many results were returned, you should do a SELECT COUNT(*) on the temporary table afterwards.

Parameters
string$queryA string containing a normal SELECT SQL query.
array$args(optional) An array of values to substitute into the query at placeholder markers.
array$options(optional) An associative array of options to control how the query is run. See the documentation for DatabaseConnection::defaultOptions() for details.
Returns
string The name of the temporary table.
quote (   $string,
  $parameter_type = \PDO::PARAM_STR 
)

Quotes a string for use in a query.

Parameters
string$stringThe string to be quoted.
int$parameter_type(optional) Provides a data type hint for drivers that have alternate quoting styles. Defaults to ::PARAM_STR.
Returns
string|bool A quoted string that is theoretically safe to pass into an SQL statement. Returns FALSE if the driver does not support quoting in this way.
See Also
::quote()
rollback (   $savepoint_name = 'drupal_transaction')

Rolls back the transaction entirely or to a named savepoint.

This method throws an exception if no transaction is active.

Parameters
string$savepoint_name(optional) The name of the savepoint. The default, 'drupal_transaction', will roll the entire transaction back.
Exceptions
\Drupal\Core\Database\TransactionOutOfOrderException
\Drupal\Core\Database\TransactionNoActiveException
See Also
::rollback()

References Connection\inTransaction(), Connection\popCommittableTransactions(), Connection\query(), and Connection\supportsTransactions().

Referenced by Connection\rollbackSavepoint().

Here is the call graph for this function:

Here is the caller graph for this function:

schema ( )

Returns a DatabaseSchema object for manipulating the schema.

This method will lazy-load the appropriate schema library file.

Returns
The database Schema object for this connection.

References Connection\getDriverClass().

Referenced by RoutingFixtures\createTables(), Connection\destroy(), RoutingFixtures\dropTables(), DbDumpCommand\fieldSizeMap(), DbDumpCommand\fieldTypeMap(), and DbDumpCommand\getTables().

Here is the call graph for this function:

Here is the caller graph for this function:

select (   $table,
  $alias = NULL,
array  $options = array() 
)

Prepares and returns a SELECT query object.

Parameters
string$tableThe base table for this query, that is, the first table in the FROM clause. This table will also be used as the "base" table for query_alter hook implementations.
string$alias(optional) The alias of the base table of this query.
$optionsAn array of options on the query.
Returns
An appropriate SelectQuery object for this database connection. Note that it may be a driver-specific subclass of SelectQuery, depending on the driver.
See Also

References Connection\getDriverClass().

Referenced by UserData\get().

Here is the call graph for this function:

Here is the caller graph for this function:

setKey (   $key)

Tells this connection object what its key is.

Parameters
string$keyThe key this connection is for.
setLogger ( Log  $logger)

Associates a logging object with this connection.

Parameters
\Drupal\Core\Database\Log$loggerThe logging object we want to use.

References Drupal\logger().

Here is the call graph for this function:

setPrefix (   $prefix)
protected

Set the list of prefixes used by this database connection.

Parameters
array | string$prefixEither a single prefix, or an array of prefixes, in any of the multiple forms documented in default.settings.php.

Referenced by Connection\__construct().

Here is the caller graph for this function:

setTarget (   $target = NULL)

Tells this connection object what its target value is.

This is needed for logging and auditing. It's sloppy to do in the constructor because the constructor for child classes has a different signature. We therefore also ensure that this function is only ever called once.

Parameters
string$target(optional) The target this connection is for.
startTransaction (   $name = '')

Returns a new DatabaseTransaction object on this connection.

Parameters
string$name(optional) The name of the savepoint.
Returns
A Transaction object.
See Also

References Connection\getDriverClass().

Here is the call graph for this function:

supportsTransactionalDDL ( )

Determines if this driver supports transactional DDL.

DDL queries are those that change the schema, such as ALTER queries.

Returns
bool TRUE if this connection supports transactions for DDL queries, FALSE otherwise.
supportsTransactions ( )

Determines if this driver supports transactions.

Returns
bool TRUE if this connection supports transactions, FALSE otherwise.

Referenced by Connection\popTransaction(), Connection\pushTransaction(), and Connection\rollback().

Here is the caller graph for this function:

tablePrefix (   $table = 'default')

Find the prefix for a table.

This function is for when you want to know the prefix of a table. This is not used in prefixTables due to performance reasons.

Parameters
string$table(optional) The table to find the prefix for.

Referenced by Connection\getFullQualifiedTableName().

Here is the caller graph for this function:

transactionDepth ( )

Determines the current transaction depth.

Returns
int The current transaction depth.

Referenced by Connection\inTransaction().

Here is the caller graph for this function:

truncate (   $table,
array  $options = array() 
)

Prepares and returns a TRUNCATE query object.

Parameters
string$tableThe table to use for the truncate statement.
array$options(optional) An array of options on the query.
Returns
A new Truncate query object.
See Also

References Connection\getDriverClass().

Here is the call graph for this function:

update (   $table,
array  $options = array() 
)

Prepares and returns an UPDATE query object.

Parameters
string$tableThe table to use for the update statement.
array$options(optional) An array of options on the query.
Returns
A new Update query object.
See Also

References Connection\getDriverClass().

Here is the call graph for this function:

upsert (   $table,
array  $options = array() 
)

Prepares and returns an UPSERT query object.

Parameters
string$tableThe table to use for the upsert query.
array$options(optional) An array of options on the query.
Returns
A new Upsert query object.
See Also

References Connection\getDriverClass().

Here is the call graph for this function:

version ( )

Returns the version of the database server.

Referenced by Connection\upsert().

Here is the caller graph for this function:


The documentation for this class was generated from the following file: