From 466137485d48d668720f08141dcaaa4aa4656d22 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 4 Dec 2010 13:28:43 -0500 Subject: [PATCH] Removing a duplicated property. Changing is_a() to instanceof as it marginally faster. Adding a comment to getConnection as it was missing it. Minor optimization to a regular expression. --- cake/libs/model/datasources/dbo_source.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index c24051675..a47ee4d74 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -88,14 +88,6 @@ class DboSource extends DataSource { */ private $__sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', 'regexp', 'similar to'); -/** - * Indicates that a transaction have been started - * - * @var boolean - * @access protected - */ - protected $_transactionStarted = false; - /** * Indicates the level of nested transactions * @@ -181,7 +173,7 @@ class DboSource extends DataSource { * @return boolean True if the database could be disconnected, else false */ function disconnect() { - if (is_a($this->_result, 'PDOStatement')) { + if ($this->_result instanceof PDOStatement) { $this->_result->closeCursor(); } unset($this->_connection); @@ -189,6 +181,11 @@ class DboSource extends DataSource { return !$this->connected; } +/** + * Get the underlying connection object. + * + * @return PDOConnection + */ public function getConnection() { return $this->_connection; } @@ -336,7 +333,7 @@ class DboSource extends DataSource { */ protected function _execute($sql, $params = array()) { $sql = trim($sql); - if (preg_match('/^CREATE|^ALTER|^DROP/i', $sql)) { + if (preg_match('/^(?:CREATE|ALTER|DROP)/i', $sql)) { $statements = array_filter(explode(';', $sql)); if (count($statements) > 1) { $result = array_map(array($this, '_execute'), $statements);