Skip to content

Commit

Permalink
Refactoring possible common code to DboSource, now that PDO abstract …
Browse files Browse the repository at this point in the history
…disconnection from source
  • Loading branch information
lorenzo committed Oct 18, 2010
1 parent f3d3ee9 commit 159776f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
17 changes: 0 additions & 17 deletions cake/libs/model/datasources/dbo/dbo_mysql.php
Expand Up @@ -165,10 +165,6 @@ function connect() {
return $this->connected;
}

public function getConnection() {
return $this->_connection;
}

/**
* Check whether the MySQL extension is installed/loaded
*
Expand All @@ -177,19 +173,6 @@ public function getConnection() {
function enabled() {
return in_array('mysql', PDO::getAvailableDrivers());
}
/**
* Disconnects from database.
*
* @return boolean True if the database could be disconnected, else false
*/
function disconnect() {
if (is_a($this->_result, 'PDOStatement')) {
$this->_result->closeCursor();
}
unset($this->_connection);
$this->connected = false;
return !$this->connected;
}

/**
* Returns an array of sources (tables) in the database.
Expand Down
23 changes: 21 additions & 2 deletions cake/libs/model/datasources/dbo_source.php
Expand Up @@ -160,9 +160,28 @@ function reconnect($config = array()) {
}

/**
* Prepares a value, or an array of values for database queries by quoting and escaping them.
* Disconnects from database.
*
* @param mixed $data A value or an array of values to prepare.
* @return boolean True if the database could be disconnected, else false
*/
function disconnect() {
if (is_a($this->_result, 'PDOStatement')) {
$this->_result->closeCursor();
}
unset($this->_connection);
$this->connected = false;
return !$this->connected;
}

public function getConnection() {
return $this->_connection;
}


/**
* Returns a quoted and escaped string of $data for use in an SQL statement.
*
* @param string $data String to be prepared for use in an SQL statement
* @param string $column The column into which this data will be inserted
* @param boolean $read Value to be used in READ or WRITE context
* @return mixed Prepared value or array of values.
Expand Down

0 comments on commit 159776f

Please sign in to comment.