From 2c9399a78aa6b272311a826bb75d141674bb9566 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 31 Mar 2012 21:58:33 -0400 Subject: [PATCH] Removed unused attribute and moved getVersion to be reused in all PDO drivers. --- lib/Cake/Model/Datasource/Database/Mysql.php | 20 ----------------- .../Model/Datasource/Database/Postgres.php | 11 ---------- .../Model/Datasource/Database/Sqlserver.php | 22 +------------------ lib/Cake/Model/Datasource/DboSource.php | 22 +++++++++---------- 4 files changed, 11 insertions(+), 64 deletions(-) diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index b5421f43d..17da3224b 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -77,17 +77,6 @@ class Mysql extends DboSource { */ protected $_useAlias = true; -/** - * Index of basic SQL commands - * - * @var array - */ - protected $_commands = array( - 'begin' => 'START TRANSACTION', - 'commit' => 'COMMIT', - 'rollback' => 'ROLLBACK' - ); - /** * List of engine specific additional field parameters used on table creating * @@ -262,15 +251,6 @@ class Mysql extends DboSource { return $this->_execute('SHOW VARIABLES LIKE ?', array('character_set_client'))->fetchObject()->Value; } -/** - * Gets the version string of the database server - * - * @return string The database encoding - */ - public function getVersion() { - return $this->_connection->getAttribute(PDO::ATTR_SERVER_VERSION); - } - /** * Query charset by collation * diff --git a/lib/Cake/Model/Datasource/Database/Postgres.php b/lib/Cake/Model/Datasource/Database/Postgres.php index 064a1cca4..29f6bbe2c 100644 --- a/lib/Cake/Model/Datasource/Database/Postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -33,17 +33,6 @@ class Postgres extends DboSource { */ public $description = "PostgreSQL DBO Driver"; -/** - * Index of basic SQL commands - * - * @var array - */ - protected $_commands = array( - 'begin' => 'BEGIN', - 'commit' => 'COMMIT', - 'rollback' => 'ROLLBACK' - ); - /** * Base driver configuration settings. Merged with user settings. * diff --git a/lib/Cake/Model/Datasource/Database/Sqlserver.php b/lib/Cake/Model/Datasource/Database/Sqlserver.php index d7882663b..adea9beb1 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlserver.php +++ b/lib/Cake/Model/Datasource/Database/Sqlserver.php @@ -98,31 +98,12 @@ class Sqlserver extends DboSource { 'boolean' => array('name' => 'bit') ); -/** - * Index of basic SQL commands - * - * @var array - */ - protected $_commands = array( - 'begin' => 'BEGIN TRANSACTION', - 'commit' => 'COMMIT', - 'rollback' => 'ROLLBACK' - ); - /** * Magic column name used to provide pagination support for SQLServer 2008 * which lacks proper limit/offset support. */ const ROW_COUNTER = '_cake_page_rownum_'; -/** - * The version of SQLServer being used. If greater than 11 - * Normal limit offset statements will be used - * - * @var string - */ - protected $_version; - /** * Connects to the database using options in the given configuration array. * @@ -151,7 +132,6 @@ class Sqlserver extends DboSource { throw new MissingConnectionException(array('class' => $e->getMessage())); } - $this->_version = $this->_connection->getAttribute(PDO::ATTR_SERVER_VERSION); return $this->connected; } @@ -515,7 +495,7 @@ class Sqlserver extends DboSource { } // For older versions use the subquery version of pagination. - if (version_compare($this->_version, '11', '<') && preg_match('/FETCH\sFIRST\s+([0-9]+)/i', $limit, $offset)) { + if (version_compare($this->getVersion(), '11', '<') && preg_match('/FETCH\sFIRST\s+([0-9]+)/i', $limit, $offset)) { preg_match('/OFFSET\s*(\d+)\s*.*?(\d+)\s*ROWS/', $limit, $limitOffset); $limit = 'TOP ' . intval($limitOffset[2]); diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 7e85cc4bb..39a90c382 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -183,17 +183,6 @@ class DboSource extends DataSource { */ protected $_transactionNesting = 0; -/** - * Index of basic SQL commands - * - * @var array - */ - protected $_commands = array( - 'begin' => 'BEGIN', - 'commit' => 'COMMIT', - 'rollback' => 'ROLLBACK' - ); - /** * Default fields that are used by the DBO * @@ -294,12 +283,21 @@ class DboSource extends DataSource { /** * Get the underlying connection object. * - * @return PDOConnection + * @return PDO */ public function getConnection() { return $this->_connection; } +/** + * Gets the version string of the database server + * + * @return string The database version + */ + public function getVersion() { + return $this->_connection->getAttribute(PDO::ATTR_SERVER_VERSION); + } + /** * Returns a quoted and escaped string of $data for use in an SQL statement. *