diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index 691a6ae..93a5529 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -176,6 +176,14 @@ public function __construct(\PDO $connection, array $connection_options) { // Initialize and prepare the connection prefix. $this->setPrefix(isset($connection_options['prefix']) ? $connection_options['prefix'] : ''); + if (!empty($connection_options['namespace'])) { + $this->setPrefix($connection_options['namespace']) + + } + else { + @trigger_error('calling \Drupal\Core\Database\Connection::__construct() without namespace key is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. See https://www.drupal.org/project/drupal/issues/3112476', E_USER_DEPRECATED); + } + // Set a Statement class, unless the driver opted out. if (!empty($this->statementClass)) { $connection->setAttribute(\PDO::ATTR_STATEMENT_CLASS, [$this->statementClass, [$this]]); @@ -638,14 +646,18 @@ public function query($query, array $args = [], $options = []) { switch ($options['return']) { case Database::RETURN_STATEMENT: return $stmt; + case Database::RETURN_AFFECTED: $stmt->allowRowCount = TRUE; return $stmt->rowCount(); + case Database::RETURN_INSERT_ID: $sequence_name = isset($options['sequence_name']) ? $options['sequence_name'] : NULL; return $this->connection->lastInsertId($sequence_name); + case Database::RETURN_NULL: return NULL; + default: throw new \PDOException('Invalid return directive: ' . $options['return']); } @@ -770,6 +782,7 @@ protected function expandArguments(&$query, &$args) { * * @param string $class * The class for which we want the potentially driver-specific class. + * * @return string * The name of the class that should be used for this driver. */ @@ -1469,7 +1482,7 @@ public function commit() { abstract public function nextId($existing_id = 0); /** - * Prepares a statement for execution and returns a statement object + * 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. @@ -1521,7 +1534,7 @@ public function quote($string, $parameter_type = \PDO::PARAM_STR) { * Extracts the SQLSTATE error from the PDOException. * * @param \Exception $e - * The exception + * The exception. * * @return string * The five character error code.