Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Removed unused attribute and moved getVersion to be reused in all PDO…
… drivers.
  • Loading branch information
jrbasso committed Apr 14, 2012
1 parent 072aee0 commit 2c9399a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 64 deletions.
20 changes: 0 additions & 20 deletions lib/Cake/Model/Datasource/Database/Mysql.php
Expand Up @@ -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
*
Expand Down Expand Up @@ -262,15 +251,6 @@ public function getEncoding() {
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
*
Expand Down
11 changes: 0 additions & 11 deletions lib/Cake/Model/Datasource/Database/Postgres.php
Expand Up @@ -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.
*
Expand Down
22 changes: 1 addition & 21 deletions lib/Cake/Model/Datasource/Database/Sqlserver.php
Expand Up @@ -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.
*
Expand Down Expand Up @@ -151,7 +132,6 @@ public function connect() {
throw new MissingConnectionException(array('class' => $e->getMessage()));
}

$this->_version = $this->_connection->getAttribute(PDO::ATTR_SERVER_VERSION);
return $this->connected;
}

Expand Down Expand Up @@ -515,7 +495,7 @@ public function renderStatement($type, $data) {
}

// 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]);
Expand Down
22 changes: 10 additions & 12 deletions lib/Cake/Model/Datasource/DboSource.php
Expand Up @@ -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
*
Expand Down Expand Up @@ -294,12 +283,21 @@ public function disconnect() {
/**
* 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.
*
Expand Down

0 comments on commit 2c9399a

Please sign in to comment.