mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Refactoring possible common code to DboSource, now that PDO abstract disconnection from source
This commit is contained in:
parent
f3d3ee92f2
commit
159776fc00
2 changed files with 21 additions and 19 deletions
|
@ -165,10 +165,6 @@ class DboMysql extends DboSource {
|
|||
return $this->connected;
|
||||
}
|
||||
|
||||
public function getConnection() {
|
||||
return $this->_connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the MySQL extension is installed/loaded
|
||||
*
|
||||
|
@ -177,19 +173,6 @@ class DboMysql extends DboSource {
|
|||
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.
|
||||
|
|
|
@ -160,9 +160,28 @@ class DboSource extends DataSource {
|
|||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
|
Loading…
Add table
Reference in a new issue