diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index 7cbe167..067cf2f 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -45,7 +45,7 @@ /** * The current database logging object for this connection. * - * @var Log + * @var \Drupal\Core\Database\Log logger */ protected $logger = NULL; @@ -114,7 +114,9 @@ /** * The schema object for this connection. * - * @var object + * Set to NULL when the schema is destroyed. + * + * @var \Drupal\Core\Database\Schema|Null */ protected $schema = NULL; @@ -141,6 +143,11 @@ /** * Constructs a Connection object. + * + * @param \PDO $connection + * The PDO database abstraction class that this class extends. + * @param array $connection_options + * The options array. */ public function __construct(\PDO $connection, array $connection_options) { // Initialize and prepare the connection prefix. @@ -224,7 +231,7 @@ public function destroy() { * that behavior and simply return NULL on failure, set this option to * FALSE. * - * @return + * @return array * An array of default query options. */ protected function defaultOptions() { @@ -244,7 +251,7 @@ protected function defaultOptions() { * is for requesting the connection information of this specific * open connection object. * - * @return + * @return array * An array of the connection information. The exact list of * properties is driver-dependent. */ @@ -295,7 +302,7 @@ protected function setPrefix($prefix) { * @param $sql * A string containing a partial or entire SQL query. * - * @return + * @return string * The properly-prefixed string. */ public function prefixTables($sql) { @@ -307,6 +314,9 @@ public function prefixTables($sql) { * * This function is for when you want to know the prefix of a table. This * is not used in prefixTables due to performance reasons. + * + * @param string $table + * (optional) The table to be searched. */ public function tablePrefix($table = 'default') { if (isset($this->prefixes[$table])) { @@ -345,7 +355,7 @@ public function prepareQuery($query) { * called once. * * @param $target - * The target this connection is for. Set to NULL (default) to disable + * (optional) The target this connection is for. Set to NULL (default) to disable * logging entirely. */ public function setTarget($target = NULL) { @@ -357,7 +367,7 @@ public function setTarget($target = NULL) { /** * Returns the target this connection is associated with. * - * @return + * @return string * The target string of this connection. */ public function getTarget() { @@ -367,7 +377,7 @@ public function getTarget() { /** * Tells this connection object what its key is. * - * @param $target + * @param string $key * The key this connection is for. */ public function setKey($key) { @@ -379,7 +389,7 @@ public function setKey($key) { /** * Returns the key this connection is associated with. * - * @return + * @return string * The key of this connection. */ public function getKey() { @@ -389,7 +399,7 @@ public function getKey() { /** * Associates a logging object with this connection. * - * @param $logger + * @param \Drupal\Core\Database\Log $logger * The logging object we want to use. */ public function setLogger(Log $logger) { @@ -418,7 +428,7 @@ public function getLogger() { * @param $field * The field name to use for the sequence. * - * @return + * @return string * A table prefix-parsed string for the sequence name. */ public function makeSequenceName($table, $field) { @@ -433,7 +443,7 @@ public function makeSequenceName($table, $field) { * @param $comments * An array of query comment strings. * - * @return + * @return string * A sanitized comment string. */ public function makeComment($comments) { @@ -475,7 +485,7 @@ public function makeComment($comments) { * @param $comment * A query comment string. * - * @return + * @return string * A sanitized version of the query comment string. */ protected function filterComment($comment = '') { @@ -489,7 +499,7 @@ protected function filterComment($comment = '') { * query. All queries executed by Drupal are executed as PDO prepared * statements. * - * @param $query + * @param string|\Drupal\Core\Database\StatementInterface $query * The 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 @@ -498,15 +508,15 @@ protected function filterComment($comment = '') { * 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. - * @param $args + * @param array $args * An 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. - * @param $options + * @param array $options * An associative array of options to control how the query is run. See * the documentation for DatabaseConnection::defaultOptions() for details. * - * @return \Drupal\Core\Database\StatementInterface + * @return \Drupal\Core\Database\StatementInterface|NULL * This method will return one of: the executed statement, the number of * rows affected by the query (not the number matched), or the generated * insert ID of the last query, depending on the value of @@ -581,12 +591,12 @@ public function query($query, array $args = array(), $options = array()) { * Drupal supports an alternate syntax for doing arrays of values. We * therefore need to expand them out into a full, executable query string. * - * @param $query + * @param string $query * The query string to modify. * @param $args * The arguments for the query. * - * @return + * @return bool * TRUE if the query was modified, FALSE otherwise. */ protected function expandArguments(&$query, &$args) { @@ -674,8 +684,10 @@ public function select($table, $alias = NULL, array $options = array()) { /** * Prepares and returns an INSERT query object. * + * @param string $table + * The name of the table associated with the query. * @param $options - * An array of options on the query. + * (optional) An array of options on the query. * * @return \Drupal\Core\Database\Query\Insert * A new Insert query object. @@ -690,8 +702,10 @@ public function insert($table, array $options = array()) { /** * Prepares and returns a MERGE query object. * + * @param string $table + * The name of the table associated with the query. * @param $options - * An array of options on the query. + * (optional) An array of options on the query. * * @return \Drupal\Core\Database\Query\Merge * A new Merge query object. @@ -707,8 +721,10 @@ public function merge($table, array $options = array()) { /** * Prepares and returns an UPDATE query object. * - * @param $options - * An array of options on the query. + * @param string $table + * The name of the table associated with the query. + * @param array $options + * (optional) An array of options on the query. * * @return \Drupal\Core\Database\Query\Update * A new Update query object. @@ -723,8 +739,10 @@ public function update($table, array $options = array()) { /** * Prepares and returns a DELETE query object. * - * @param $options - * An array of options on the query. + * @param string $table + * The name of the table associated with the query. + * @param array $options + * (optional) An array of options on the query. * * @return \Drupal\Core\Database\Query\Delete * A new Delete query object. @@ -739,8 +757,10 @@ public function delete($table, array $options = array()) { /** * Prepares and returns a TRUNCATE query object. * + * @param string $table + * The name of the table associated with the query. * @param $options - * An array of options on the query. + * (optional) An array of options on the query. * * @return \Drupal\Core\Database\Query\Truncate * A new Truncate query object. @@ -775,6 +795,8 @@ public function schema() { * For some database drivers, it may also wrap the database name in * database-specific escape characters. * + * @param string $database + * The unescaped database name. * @return string * The sanitized database name string. */ @@ -789,7 +811,9 @@ public function escapeDatabase($database) { * For some database drivers, it may also wrap the table name in * database-specific escape characters. * - * @return + * @param string $table + * The unescaped table name. + * @return string * The sanitized table name string. */ public function escapeTable($table) { @@ -803,7 +827,9 @@ public function escapeTable($table) { * For some database drivers, it may also wrap the field name in * database-specific escape characters. * - * @return + * @param string $field + * The unescaped field name. + * @return string * The sanitized field name string. */ public function escapeField($field) { @@ -818,7 +844,9 @@ public function escapeField($field) { * DatabaseConnection::escapeTable(), this doesn't allow the period (".") * because that is not allowed in aliases. * - * @return + * @param string $field + * The unescpaed alias name string. + * @return string * The sanitized field name string. */ public function escapeAlias($field) { @@ -844,10 +872,10 @@ public function escapeAlias($field) { * Backslash is defined as escape character for LIKE patterns in * Drupal\Core\Database\Query\Condition::mapConditionOperator(). * - * @param $string + * @param string $string * The string to escape. * - * @return + * @return string * The escaped string. */ public function escapeLike($string) { @@ -857,7 +885,7 @@ public function escapeLike($string) { /** * Determines if there is an active transaction open. * - * @return + * @return bool * TRUE if we're currently in a transaction, FALSE otherwise. */ public function inTransaction() { @@ -875,7 +903,7 @@ public function transactionDepth() { * Returns a new DatabaseTransaction object on this connection. * * @param $name - * Optional name of the savepoint. + * (optional) The name of the savepoint. * * @return \Drupal\Core\Database\Transaction * A Transaction object. @@ -893,7 +921,7 @@ public function startTransaction($name = '') { * This method throws an exception if no transaction is active. * * @param $savepoint_name - * The name of the savepoint. The default, 'drupal_transaction', will roll + * (optional) The name of the savepoint. The default, 'drupal_transaction', will roll * the entire transaction back. * * @throws \Drupal\Core\Database\TransactionNoActiveException @@ -947,6 +975,9 @@ public function rollback($savepoint_name = 'drupal_transaction') { * * If no transaction is already active, we begin a new transaction. * + * @param string $name + * The name of the transaction. + * * @throws \Drupal\Core\Database\TransactionNameNonUniqueException * * @see \Drupal\Core\Database\Transaction @@ -1033,16 +1064,16 @@ protected function popCommittableTransactions() { * separate parameters so that they can be properly escaped to avoid SQL * injection attacks. * - * @param $query + * @param string $query * A string containing an SQL query. - * @param $args - * An array of values to substitute into the query at placeholder markers. - * @param $from + * @param int $from * The first result row to return. - * @param $count + * @param int $count * The maximum number of result rows to return. - * @param $options - * An array of options on the query. + * @param array $args + * (optional) An array of values to substitute into the query at placeholder markers. + * @param array $options + * (optional) An array of options on the query. * * @return \Drupal\Core\Database\StatementInterface * A database query result resource, or NULL if the query was not executed @@ -1053,7 +1084,7 @@ protected function popCommittableTransactions() { /** * Generates a temporary table name. * - * @return + * @return string * A table name. */ protected function generateTemporaryTableName() { @@ -1072,12 +1103,12 @@ protected function generateTemporaryTableName() { * Note that if you need to know how many results were returned, you should do * a SELECT COUNT(*) on the temporary table afterwards. * - * @param $query + * @param string $query * A string containing a normal SELECT SQL query. - * @param $args - * An array of values to substitute into the query at placeholder markers. - * @param $options - * An associative array of options to control how the query is run. See + * @param array $args + * (optional) An array of values to substitute into the query at placeholder markers. + * @param array $options + * (optional) An associative array of options to control how the query is run. See * the documentation for DatabaseConnection::defaultOptions() for details. * * @return @@ -1105,7 +1136,7 @@ public function version() { /** * Determines if this driver supports transactions. * - * @return + * @return bool * TRUE if this connection supports transactions, FALSE otherwise. */ public function supportsTransactions() { @@ -1117,7 +1148,7 @@ public function supportsTransactions() { * * DDL queries are those that change the schema, such as ALTER queries. * - * @return + * @return bool * TRUE if this connection supports transactions for DDL queries, FALSE * otherwise. */ @@ -1149,7 +1180,7 @@ public function supportsTransactionalDDL() { * overridable lookup function. Database connections should define only * those operators they wish to be handled differently than the default. * - * @param $operator + * @param string $operator * The condition operator, such as "IN", "BETWEEN", etc. Case-sensitive. * * @return @@ -1184,7 +1215,7 @@ public function commit() { * value. Or sometimes you just need a unique integer. * * @param $existing_id - * After a database import, it might be that the sequences table is behind, + * (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. *