mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
* MySQL: got mysqli extension working and make it default for EGroupware, as mysql is now officially deprecated, existing installs need to be switched manually in header.inc.php or Setup >> Manage header
This commit is contained in:
parent
cd7b9b0910
commit
3996f8a936
@ -121,6 +121,19 @@ class ADODB_mysqli extends ADOConnection {
|
|||||||
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
|
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if we are connected
|
||||||
|
*
|
||||||
|
* Reimplemented as check in ADOConnection::IsConnected will allways return true, as _connectionID is mysqli object!
|
||||||
|
*
|
||||||
|
* @see ADOConnection::IsConnected()
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function IsConnected()
|
||||||
|
{
|
||||||
|
return $this->_connectionID && @mysqli_ping($this->_connectionID);
|
||||||
|
}
|
||||||
|
|
||||||
function IfNull( $field, $ifNull )
|
function IfNull( $field, $ifNull )
|
||||||
{
|
{
|
||||||
return " IFNULL($field, $ifNull) "; // if MySQL
|
return " IFNULL($field, $ifNull) "; // if MySQL
|
||||||
@ -692,13 +705,18 @@ class ADODB_mysqli extends ADOConnection {
|
|||||||
*
|
*
|
||||||
* mysqli_set_charset is php5.1+, the query used here works since mysql4.1
|
* mysqli_set_charset is php5.1+, the query used here works since mysql4.1
|
||||||
*
|
*
|
||||||
|
* mysqli_set_charset is strongly prefered, as mysqli_real_escape only uses charset set this way!
|
||||||
|
*
|
||||||
* @param string $charset_name
|
* @param string $charset_name
|
||||||
* @return boolean true on success, false otherwise
|
* @return boolean true on success, false otherwise
|
||||||
*/
|
*/
|
||||||
function SetCharSet($charset_name)
|
function SetCharSet($charset_name)
|
||||||
{
|
{
|
||||||
$mysql_charset = isset($this->charset2mysql[$charset_name]) ? $this->charset2mysql[$charset_name] : $charset_name;
|
$mysql_charset = isset($this->charset2mysql[$charset_name]) ? $this->charset2mysql[$charset_name] : $charset_name;
|
||||||
if (!mysqli_query($this->_connectionID,'SET NAMES '.$this->qstr($mysql_charset))) return false;
|
if (function_exists('mysqli_set_charset')) {
|
||||||
|
if (!mysqli_set_charset($this->_connectionID,$mysql_charset)) return false;
|
||||||
|
}
|
||||||
|
elseif (!mysqli_query($this->_connectionID,'SET NAMES '.$this->qstr($mysql_charset))) return false;
|
||||||
if ($this->GetCharSet()) {
|
if ($this->GetCharSet()) {
|
||||||
return $this->charSet == $charset_name || $this->charset2mysql[$this->charSet] == $charset_name;
|
return $this->charSet == $charset_name || $this->charset2mysql[$this->charSet] == $charset_name;
|
||||||
}
|
}
|
||||||
|
@ -410,14 +410,10 @@ class egw_db
|
|||||||
throw new egw_exception_db_connection("No ADOdb support for '$type' ($this->Type) !!!");
|
throw new egw_exception_db_connection("No ADOdb support for '$type' ($this->Type) !!!");
|
||||||
}
|
}
|
||||||
$connect = $GLOBALS['egw_info']['server']['db_persistent'] ? 'PConnect' : 'Connect';
|
$connect = $GLOBALS['egw_info']['server']['db_persistent'] ? 'PConnect' : 'Connect';
|
||||||
if (($Ok = $this->Link_ID->$connect($Host, $User, $Password)))
|
if (($Ok = $this->Link_ID->$connect($Host, $User, $Password, $Database)))
|
||||||
{
|
{
|
||||||
$this->ServerInfo = $this->Link_ID->ServerInfo();
|
$this->ServerInfo = $this->Link_ID->ServerInfo();
|
||||||
$this->set_capabilities($type,$this->ServerInfo['version']);
|
$this->set_capabilities($type,$this->ServerInfo['version']);
|
||||||
if($Database)
|
|
||||||
{
|
|
||||||
$Ok = $this->Link_ID->SelectDB($Database);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!$Ok)
|
if (!$Ok)
|
||||||
{
|
{
|
||||||
@ -447,8 +443,7 @@ class egw_db
|
|||||||
$this->Link_ID =& $GLOBALS['egw']->ADOdb;
|
$this->Link_ID =& $GLOBALS['egw']->ADOdb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// next ADOdb version: if (!$this->Link_ID->isConnected()) $this->Link_ID->Connect();
|
if (!$this->Link_ID->isConnected()) $this->Link_ID->Connect();
|
||||||
if (!$this->Link_ID->_connectionID) $this->Link_ID->Connect();
|
|
||||||
|
|
||||||
if ($new_connection)
|
if ($new_connection)
|
||||||
{
|
{
|
||||||
|
@ -26,10 +26,10 @@ class setup_header
|
|||||||
* @var array with php-extension / ADOdb drive names => describtiv label
|
* @var array with php-extension / ADOdb drive names => describtiv label
|
||||||
*/
|
*/
|
||||||
var $db_fullnames = array(
|
var $db_fullnames = array(
|
||||||
|
'mysqli' => 'MySQLi (recommended, incl. transactions)',
|
||||||
|
'mysql' => 'MySQL (deprecated)',
|
||||||
|
'mysqlt' => 'MySQL (deprecated, transactions)',
|
||||||
'pgsql' => 'PostgreSQL',
|
'pgsql' => 'PostgreSQL',
|
||||||
'mysql' => 'MySQL',
|
|
||||||
'mysqli' => 'MySQLi (php5)',
|
|
||||||
'mysqlt' => 'MySQL (with transactions)',
|
|
||||||
'mssql' => 'MS SQL Server',
|
'mssql' => 'MS SQL Server',
|
||||||
'odbc_mssql' => 'MS SQL Server via ODBC',
|
'odbc_mssql' => 'MS SQL Server via ODBC',
|
||||||
'oracle' => 'Oracle',
|
'oracle' => 'Oracle',
|
||||||
@ -84,7 +84,7 @@ class setup_header
|
|||||||
function domain_defaults($user='admin',$passwd='',$supported_db=null)
|
function domain_defaults($user='admin',$passwd='',$supported_db=null)
|
||||||
{
|
{
|
||||||
if (is_null($supported_db)) $supported_db = $this->check_db_support($null);
|
if (is_null($supported_db)) $supported_db = $this->check_db_support($null);
|
||||||
$default_db = count($supported_db) ? $supported_db[0] : 'mysql';
|
$default_db = count($supported_db) ? $supported_db[0] : 'mysqli';
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'db_host' => 'localhost',
|
'db_host' => 'localhost',
|
||||||
@ -232,8 +232,8 @@ class setup_header
|
|||||||
$supported_db = $detected = array();
|
$supported_db = $detected = array();
|
||||||
foreach(array(
|
foreach(array(
|
||||||
// short => array(extension,func_to_check,supported_db(s))
|
// short => array(extension,func_to_check,supported_db(s))
|
||||||
'mysql' => array('mysql','mysql_connect','mysql'),
|
|
||||||
'mysqli' => array('mysql','mysqli_connect','mysqli'),
|
'mysqli' => array('mysql','mysqli_connect','mysqli'),
|
||||||
|
'mysql' => array('mysql','mysql_connect','mysql'),
|
||||||
'mysqlt' => array('mysql','mysql_connect','mysqlt'),
|
'mysqlt' => array('mysql','mysql_connect','mysqlt'),
|
||||||
'pgsql' => array('pgsql','pg_connect','pgsql'),
|
'pgsql' => array('pgsql','pg_connect','pgsql'),
|
||||||
'mssql' => array('mssql','mssql_connect','mssql'),
|
'mssql' => array('mssql','mssql_connect','mssql'),
|
||||||
|
Loading…
Reference in New Issue
Block a user