* 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:
Ralf Becker 2013-05-26 09:32:41 +00:00
parent cd7b9b0910
commit 3996f8a936
3 changed files with 221 additions and 208 deletions

View File

@ -121,6 +121,19 @@ class ADODB_mysqli extends ADOConnection {
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 )
{
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 strongly prefered, as mysqli_real_escape only uses charset set this way!
*
* @param string $charset_name
* @return boolean true on success, false otherwise
*/
function SetCharSet($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()) {
return $this->charSet == $charset_name || $this->charset2mysql[$this->charSet] == $charset_name;
}

View File

@ -410,14 +410,10 @@ class egw_db
throw new egw_exception_db_connection("No ADOdb support for '$type' ($this->Type) !!!");
}
$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->set_capabilities($type,$this->ServerInfo['version']);
if($Database)
{
$Ok = $this->Link_ID->SelectDB($Database);
}
}
if (!$Ok)
{
@ -447,8 +443,7 @@ class egw_db
$this->Link_ID =& $GLOBALS['egw']->ADOdb;
}
}
// next ADOdb version: if (!$this->Link_ID->isConnected()) $this->Link_ID->Connect();
if (!$this->Link_ID->_connectionID) $this->Link_ID->Connect();
if (!$this->Link_ID->isConnected()) $this->Link_ID->Connect();
if ($new_connection)
{

View File

@ -26,10 +26,10 @@ class setup_header
* @var array with php-extension / ADOdb drive names => describtiv label
*/
var $db_fullnames = array(
'mysqli' => 'MySQLi (recommended, incl. transactions)',
'mysql' => 'MySQL (deprecated)',
'mysqlt' => 'MySQL (deprecated, transactions)',
'pgsql' => 'PostgreSQL',
'mysql' => 'MySQL',
'mysqli' => 'MySQLi (php5)',
'mysqlt' => 'MySQL (with transactions)',
'mssql' => 'MS SQL Server',
'odbc_mssql' => 'MS SQL Server via ODBC',
'oracle' => 'Oracle',
@ -84,7 +84,7 @@ class setup_header
function domain_defaults($user='admin',$passwd='',$supported_db=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(
'db_host' => 'localhost',
@ -232,8 +232,8 @@ class setup_header
$supported_db = $detected = array();
foreach(array(
// short => array(extension,func_to_check,supported_db(s))
'mysql' => array('mysql','mysql_connect','mysql'),
'mysqli' => array('mysql','mysqli_connect','mysqli'),
'mysql' => array('mysql','mysql_connect','mysql'),
'mysqlt' => array('mysql','mysql_connect','mysqlt'),
'pgsql' => array('pgsql','pg_connect','pgsql'),
'mssql' => array('mssql','mssql_connect','mssql'),