mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge branch 'datasource-enabled' into 1.2
This commit is contained in:
commit
02df92a3a3
12 changed files with 97 additions and 2 deletions
|
@ -364,6 +364,16 @@ class DataSource extends Object {
|
|||
function lastAffected($source = null) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Check whether the conditions for the Datasource being available
|
||||
* are satisfied. Often used from connect() to check for support
|
||||
* before establishing a connection.
|
||||
*
|
||||
* @return boolean Whether or not the Datasources conditions for use are met.
|
||||
**/
|
||||
function enabled() {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Returns true if the DataSource supports the given interface (method)
|
||||
*
|
||||
|
|
|
@ -102,7 +102,9 @@ class DboAdodb extends DboSource {
|
|||
$adodb_driver = substr($config['connect'], 0, $persistent);
|
||||
$connect = 'PConnect';
|
||||
}
|
||||
|
||||
if (!$this->enabled()) {
|
||||
return false;
|
||||
}
|
||||
$this->_adodb = NewADOConnection($adodb_driver);
|
||||
|
||||
$this->_adodbDataDict = NewDataDictionary($this->_adodb, $adodb_driver);
|
||||
|
@ -114,6 +116,14 @@ class DboAdodb extends DboSource {
|
|||
$this->_adodbMetatyper = &$this->_adodb->execute('Select 1');
|
||||
return $this->connected;
|
||||
}
|
||||
/**
|
||||
* Check that AdoDB is available.
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return function_exists('NewADOConnection');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
|
|
@ -136,6 +136,14 @@ class DboDb2 extends DboSource {
|
|||
}
|
||||
return $this->connected;
|
||||
}
|
||||
/**
|
||||
* Check that the DB2 extension is installed/loaded
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return extension_loaded('ibm_db2');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
|
|
@ -127,9 +127,18 @@ class DboFirebird extends DboSource {
|
|||
$connect = $config['connect'];
|
||||
|
||||
$this->connected = false;
|
||||
|
||||
$this->connection = $connect($config['host'] . ':' . $config['database'], $config['login'], $config['password']);
|
||||
$this->connected = true;
|
||||
}
|
||||
/**
|
||||
* Check that the interbase extension is loaded
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return extension_loaded('interbase');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
|
|
@ -152,6 +152,14 @@ class DboMssql extends DboSource {
|
|||
}
|
||||
return $this->connected;
|
||||
}
|
||||
/**
|
||||
* Check that MsSQL is installed/loaded
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return extension_loaded('mssql');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
|
|
@ -388,6 +388,14 @@ class DboMysql extends DboMysqlBase {
|
|||
|
||||
return $this->connected;
|
||||
}
|
||||
/**
|
||||
* Check whether the MySQL extension is installed/loaded
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return extension_loaded('mysql');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
|
|
@ -83,6 +83,14 @@ class DboMysqli extends DboMysqlBase {
|
|||
}
|
||||
return $this->connected;
|
||||
}
|
||||
/**
|
||||
* Check that MySQLi is installed/enabled
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return extension_loaded('mysqli');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
|
|
@ -105,6 +105,14 @@ class DboOdbc extends DboSource {
|
|||
|
||||
return $this->connected;
|
||||
}
|
||||
/**
|
||||
* Check if the ODBC extension is installed/loaded
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return extension_loaded('odbc');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
|
|
@ -122,6 +122,14 @@ class DboPostgres extends DboSource {
|
|||
}
|
||||
return $this->connected;
|
||||
}
|
||||
/**
|
||||
* Check if PostgreSQL is enabled/loaded
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return extension_loaded('pgsql');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
|
|
@ -113,6 +113,14 @@ class DboSqlite extends DboSource {
|
|||
}
|
||||
return $this->connected;
|
||||
}
|
||||
/**
|
||||
* Check that SQLite is enabled/installed
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return extension_loaded('sqlite');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
|
|
@ -102,6 +102,14 @@ class DboSybase extends DboSource {
|
|||
$this->connected = sybase_select_db($config['database'], $this->connection);
|
||||
return $this->connected;
|
||||
}
|
||||
/**
|
||||
* Check that one of the sybase extensions is installed
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return extension_loaded('sybase') || extension_loaded('sybase_ct');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
|
|
@ -91,7 +91,9 @@ class DboSource extends DataSource {
|
|||
}
|
||||
parent::__construct($config);
|
||||
$this->fullDebug = Configure::read() > 1;
|
||||
|
||||
if (!$this->enabled()) {
|
||||
return false;
|
||||
}
|
||||
if ($autoConnect) {
|
||||
return $this->connect();
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue