mirror of
https://github.com/dg/dibi.git
synced 2025-10-28 20:28:33 +01:00
* support for default values (mysql.default_user etc...)
This commit is contained in:
@@ -45,10 +45,15 @@ class DibiMySqliDriver extends DibiDriver {
|
||||
if (!extension_loaded('mysqli'))
|
||||
throw new DibiException("PHP extension 'mysqli' is not loaded");
|
||||
|
||||
if (empty($config['host'])) $config['host'] = 'localhost';
|
||||
|
||||
foreach (array('username', 'password', 'database', 'port') as $var)
|
||||
if (!isset($config[$var])) $config[$var] = NULL;
|
||||
// default values
|
||||
if (empty($config['username'])) $config['username'] = ini_get('mysqli.default_user');
|
||||
if (empty($config['password'])) $config['password'] = ini_get('mysqli.default_password');
|
||||
if (empty($config['host'])) {
|
||||
$config['host'] = ini_get('mysqli.default_host');
|
||||
if (empty($config['port'])) ini_get('mysqli.default_port');
|
||||
if (empty($config['host'])) $config['host'] = 'localhost';
|
||||
}
|
||||
if (!isset($config['database'])) $config['database'] = NULL;
|
||||
|
||||
$conn = @mysqli_connect($config['host'], $config['username'], $config['password'], $config['database'], $config['port']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user