- Patch #337926 by Damien Tournoud: clean-up lower case handling.
parent
8900c6156d
commit
71a22f1c1f
|
@ -215,7 +215,14 @@ abstract class DatabaseConnection extends PDO {
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $statementClass = NULL;
|
protected $statementClass = 'DatabaseStatementBase';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this database connection supports transactions.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $transactionSupport = TRUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The schema object for this connection.
|
* The schema object for this connection.
|
||||||
|
@ -225,11 +232,6 @@ abstract class DatabaseConnection extends PDO {
|
||||||
protected $schema = NULL;
|
protected $schema = NULL;
|
||||||
|
|
||||||
function __construct($dsn, $username, $password, $driver_options = array()) {
|
function __construct($dsn, $username, $password, $driver_options = array()) {
|
||||||
// Fallback to DatabaseStatementBase if the driver has not specified one.
|
|
||||||
if (empty($this->statementClass)) {
|
|
||||||
$this->statementClass = 'DatabaseStatementBase';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Because the other methods don't seem to work right.
|
// Because the other methods don't seem to work right.
|
||||||
$driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
|
$driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
|
||||||
|
|
||||||
|
@ -237,7 +239,7 @@ abstract class DatabaseConnection extends PDO {
|
||||||
parent::__construct($dsn, $username, $password, $driver_options);
|
parent::__construct($dsn, $username, $password, $driver_options);
|
||||||
|
|
||||||
// Set a specific PDOStatement class if the driver requires that.
|
// Set a specific PDOStatement class if the driver requires that.
|
||||||
if ($this->statementClass != 'PDOStatement') {
|
if (!empty($this->statementClass)) {
|
||||||
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this)));
|
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -734,7 +736,9 @@ abstract class DatabaseConnection extends PDO {
|
||||||
/**
|
/**
|
||||||
* Determine if this driver supports transactions.
|
* Determine if this driver supports transactions.
|
||||||
*/
|
*/
|
||||||
abstract public function supportsTransactions();
|
public function supportsTransactions() {
|
||||||
|
return $this->transactionSupport;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type of the database being accessed.
|
* Returns the type of the database being accessed.
|
||||||
|
|
|
@ -13,11 +13,14 @@
|
||||||
|
|
||||||
class DatabaseConnection_mysql extends DatabaseConnection {
|
class DatabaseConnection_mysql extends DatabaseConnection {
|
||||||
|
|
||||||
protected $transactionSupport = FALSE;
|
|
||||||
|
|
||||||
public function __construct(Array $connection_options = array()) {
|
public function __construct(Array $connection_options = array()) {
|
||||||
$this->transactionSupport = isset($connection_options['transactions']) ? $connection_options['transactions'] : FALSE;
|
// This driver defaults to non transaction support.
|
||||||
$connection_options['port'] = !empty($connection_options['port']) ? $connection_options['port'] : 3306;
|
$this->transactionSupport = !empty($connection_option['transactions']);
|
||||||
|
|
||||||
|
// Default to TCP connection on port 3306.
|
||||||
|
if (empty($connection_options['port'])) {
|
||||||
|
$connection_options['port'] = 3306;
|
||||||
|
}
|
||||||
|
|
||||||
$dsn = 'mysql:host=' . $connection_options['host'] . ';port=' . $connection_options['port'] . ';dbname=' . $connection_options['database'];
|
$dsn = 'mysql:host=' . $connection_options['host'] . ';port=' . $connection_options['port'] . ';dbname=' . $connection_options['database'];
|
||||||
parent::__construct($dsn, $connection_options['username'], $connection_options['password'], array(
|
parent::__construct($dsn, $connection_options['username'], $connection_options['password'], array(
|
||||||
|
@ -53,10 +56,6 @@ class DatabaseConnection_mysql extends DatabaseConnection {
|
||||||
return 'mysql';
|
return 'mysql';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsTransactions() {
|
|
||||||
return $this->transactionSupport;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function mapConditionOperator($operator) {
|
public function mapConditionOperator($operator) {
|
||||||
// We don't want to override any of the defaults.
|
// We don't want to override any of the defaults.
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -92,7 +92,7 @@ class DatabaseSchema_mysql extends DatabaseSchema {
|
||||||
$sql .= ' auto_increment';
|
$sql .= ' auto_increment';
|
||||||
}
|
}
|
||||||
|
|
||||||
// $spec['default'] can be NULL, so we explicitely check for the key here.
|
// $spec['default'] can be NULL, so we explicitly check for the key here.
|
||||||
if (array_key_exists('default', $spec)) {
|
if (array_key_exists('default', $spec)) {
|
||||||
if (is_string($spec['default'])) {
|
if (is_string($spec['default'])) {
|
||||||
$spec['default'] = "'" . $spec['default'] . "'";
|
$spec['default'] = "'" . $spec['default'] . "'";
|
||||||
|
|
|
@ -13,11 +13,14 @@
|
||||||
|
|
||||||
class DatabaseConnection_pgsql extends DatabaseConnection {
|
class DatabaseConnection_pgsql extends DatabaseConnection {
|
||||||
|
|
||||||
protected $transactionSupport = TRUE;
|
|
||||||
|
|
||||||
public function __construct(Array $connection_options = array()) {
|
public function __construct(Array $connection_options = array()) {
|
||||||
$this->transactionSupport = isset($connection_options['transactions']) ? $connection_options['transactions'] : TRUE;
|
// This driver defaults to transaction support, except if explicitly passed FALSE.
|
||||||
$connection_options['port'] = !empty($connection_options['port']) ? $connection_options['port'] : 5432;
|
$this->transactionSupport = !isset($connection_options['transactions']) || $connection_options['transactions'] === FALSE;
|
||||||
|
|
||||||
|
// Default to TCP connection on port 5432.
|
||||||
|
if (empty($connection_options['port'])) {
|
||||||
|
$connection_options['port'] = 5432;
|
||||||
|
}
|
||||||
|
|
||||||
$dsn = 'pgsql:host=' . $connection_options['host'] . ' dbname=' . $connection_options['database'] . ' port=' . $connection_options['port'];
|
$dsn = 'pgsql:host=' . $connection_options['host'] . ' dbname=' . $connection_options['database'] . ' port=' . $connection_options['port'];
|
||||||
parent::__construct($dsn, $connection_options['username'], $connection_options['password'], array(
|
parent::__construct($dsn, $connection_options['username'], $connection_options['password'], array(
|
||||||
|
@ -86,10 +89,6 @@ class DatabaseConnection_pgsql extends DatabaseConnection {
|
||||||
return 'pgsql';
|
return 'pgsql';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsTransactions() {
|
|
||||||
return $this->transactionSupport;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function mapConditionOperator($operator) {
|
public function mapConditionOperator($operator) {
|
||||||
static $specials = array(
|
static $specials = array(
|
||||||
// In PostgreSQL, 'LIKE' is case-sensitive. For case-insensitive LIKE
|
// In PostgreSQL, 'LIKE' is case-sensitive. For case-insensitive LIKE
|
||||||
|
|
|
@ -18,20 +18,14 @@ include_once DRUPAL_ROOT . '/includes/database/prefetch.inc';
|
||||||
*/
|
*/
|
||||||
class DatabaseConnection_sqlite extends DatabaseConnection {
|
class DatabaseConnection_sqlite extends DatabaseConnection {
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates that this connection supports transactions.
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected $transactionSupport = TRUE;
|
|
||||||
|
|
||||||
public function __construct(Array $connection_options = array()) {
|
public function __construct(Array $connection_options = array()) {
|
||||||
// We don't need a specific PDOStatement class here, we simulate it below.
|
// We don't need a specific PDOStatement class here, we simulate it below.
|
||||||
$this->statementClass = 'PDOStatement';
|
$this->statementClass = NULL;
|
||||||
$this->transactionSupport = isset($connection_options['transactions']) ? $connection_options['transactions'] : TRUE;
|
|
||||||
|
|
||||||
$dns = 'sqlite:'. $connection_options['database'];
|
// This driver defaults to transaction support, except if explicitly passed FALSE.
|
||||||
parent::__construct($dns, '', '', array(
|
$this->transactionSupport = !isset($connection_options['transactions']) || $connection_options['transactions'] === FALSE;
|
||||||
|
|
||||||
|
parent::__construct('sqlite:'. $connection_options['database'], '', '', array(
|
||||||
// Force column names to lower case.
|
// Force column names to lower case.
|
||||||
PDO::ATTR_CASE => PDO::CASE_LOWER,
|
PDO::ATTR_CASE => PDO::CASE_LOWER,
|
||||||
));
|
));
|
||||||
|
@ -141,10 +135,6 @@ class DatabaseConnection_sqlite extends DatabaseConnection {
|
||||||
return 'sqlite';
|
return 'sqlite';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsTransactions() {
|
|
||||||
return $this->transactionSupport;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function mapConditionOperator($operator) {
|
public function mapConditionOperator($operator) {
|
||||||
// We don't want to override any of the defaults.
|
// We don't want to override any of the defaults.
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue