Skip to content

Commit 2c9399a

Browse files
committed
Removed unused attribute and moved getVersion to be reused in all PDO drivers.
1 parent 072aee0 commit 2c9399a

File tree

4 files changed

+11
-64
lines changed

4 files changed

+11
-64
lines changed

lib/Cake/Model/Datasource/Database/Mysql.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,6 @@ class Mysql extends DboSource {
7777
*/
7878
protected $_useAlias = true;
7979

80-
/**
81-
* Index of basic SQL commands
82-
*
83-
* @var array
84-
*/
85-
protected $_commands = array(
86-
'begin' => 'START TRANSACTION',
87-
'commit' => 'COMMIT',
88-
'rollback' => 'ROLLBACK'
89-
);
90-
9180
/**
9281
* List of engine specific additional field parameters used on table creating
9382
*
@@ -262,15 +251,6 @@ public function getEncoding() {
262251
return $this->_execute('SHOW VARIABLES LIKE ?', array('character_set_client'))->fetchObject()->Value;
263252
}
264253

265-
/**
266-
* Gets the version string of the database server
267-
*
268-
* @return string The database encoding
269-
*/
270-
public function getVersion() {
271-
return $this->_connection->getAttribute(PDO::ATTR_SERVER_VERSION);
272-
}
273-
274254
/**
275255
* Query charset by collation
276256
*

lib/Cake/Model/Datasource/Database/Postgres.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,6 @@ class Postgres extends DboSource {
3333
*/
3434
public $description = "PostgreSQL DBO Driver";
3535

36-
/**
37-
* Index of basic SQL commands
38-
*
39-
* @var array
40-
*/
41-
protected $_commands = array(
42-
'begin' => 'BEGIN',
43-
'commit' => 'COMMIT',
44-
'rollback' => 'ROLLBACK'
45-
);
46-
4736
/**
4837
* Base driver configuration settings. Merged with user settings.
4938
*

lib/Cake/Model/Datasource/Database/Sqlserver.php

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -98,31 +98,12 @@ class Sqlserver extends DboSource {
9898
'boolean' => array('name' => 'bit')
9999
);
100100

101-
/**
102-
* Index of basic SQL commands
103-
*
104-
* @var array
105-
*/
106-
protected $_commands = array(
107-
'begin' => 'BEGIN TRANSACTION',
108-
'commit' => 'COMMIT',
109-
'rollback' => 'ROLLBACK'
110-
);
111-
112101
/**
113102
* Magic column name used to provide pagination support for SQLServer 2008
114103
* which lacks proper limit/offset support.
115104
*/
116105
const ROW_COUNTER = '_cake_page_rownum_';
117106

118-
/**
119-
* The version of SQLServer being used. If greater than 11
120-
* Normal limit offset statements will be used
121-
*
122-
* @var string
123-
*/
124-
protected $_version;
125-
126107
/**
127108
* Connects to the database using options in the given configuration array.
128109
*
@@ -151,7 +132,6 @@ public function connect() {
151132
throw new MissingConnectionException(array('class' => $e->getMessage()));
152133
}
153134

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

@@ -515,7 +495,7 @@ public function renderStatement($type, $data) {
515495
}
516496

517497
// For older versions use the subquery version of pagination.
518-
if (version_compare($this->_version, '11', '<') && preg_match('/FETCH\sFIRST\s+([0-9]+)/i', $limit, $offset)) {
498+
if (version_compare($this->getVersion(), '11', '<') && preg_match('/FETCH\sFIRST\s+([0-9]+)/i', $limit, $offset)) {
519499
preg_match('/OFFSET\s*(\d+)\s*.*?(\d+)\s*ROWS/', $limit, $limitOffset);
520500

521501
$limit = 'TOP ' . intval($limitOffset[2]);

lib/Cake/Model/Datasource/DboSource.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,6 @@ class DboSource extends DataSource {
183183
*/
184184
protected $_transactionNesting = 0;
185185

186-
/**
187-
* Index of basic SQL commands
188-
*
189-
* @var array
190-
*/
191-
protected $_commands = array(
192-
'begin' => 'BEGIN',
193-
'commit' => 'COMMIT',
194-
'rollback' => 'ROLLBACK'
195-
);
196-
197186
/**
198187
* Default fields that are used by the DBO
199188
*
@@ -294,12 +283,21 @@ public function disconnect() {
294283
/**
295284
* Get the underlying connection object.
296285
*
297-
* @return PDOConnection
286+
* @return PDO
298287
*/
299288
public function getConnection() {
300289
return $this->_connection;
301290
}
302291

292+
/**
293+
* Gets the version string of the database server
294+
*
295+
* @return string The database version
296+
*/
297+
public function getVersion() {
298+
return $this->_connection->getAttribute(PDO::ATTR_SERVER_VERSION);
299+
}
300+
303301
/**
304302
* Returns a quoted and escaped string of $data for use in an SQL statement.
305303
*

0 commit comments

Comments
 (0)