mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 08:23:12 +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
prefering mysqli for new installs
This commit is contained in:
parent
d46bd621ae
commit
e72d937e19
@ -24,7 +24,7 @@ $config = array(
|
||||
'domain' => 'default',
|
||||
'config_user' => 'admin',
|
||||
'config_passwd' => randomstring(),
|
||||
'db_type' => 'mysql',
|
||||
'db_type' => 'mysqli',
|
||||
'db_host' => 'localhost',
|
||||
'db_port' => 3306,
|
||||
'db_name' => 'egroupware',
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -418,14 +418,10 @@ class egw_db
|
||||
return null; // in case error-reporting = 'no'
|
||||
}
|
||||
$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)
|
||||
{
|
||||
@ -456,8 +452,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)
|
||||
{
|
||||
|
@ -270,7 +270,7 @@ class setup_cmd_database extends setup_cmd
|
||||
* @param string $db_type='mysql'
|
||||
* @return array
|
||||
*/
|
||||
static function defaults($db_type='mysql')
|
||||
static function defaults($db_type='mysqli')
|
||||
{
|
||||
switch($db_type)
|
||||
{
|
||||
|
@ -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'),
|
||||
|
Loading…
Reference in New Issue
Block a user