Database connection tweaks
This commit is contained in:
parent
31ba0881ea
commit
dcdf581998
@ -158,20 +158,16 @@ class Query_Builder {
|
||||
// Convert array to object
|
||||
if (is_array($params))
|
||||
{
|
||||
$p = new StdClass();
|
||||
|
||||
foreach($params as $key => $val)
|
||||
{
|
||||
$p->$key = $val;
|
||||
}
|
||||
|
||||
$p = new ArrayObject($params);
|
||||
$params = $p;
|
||||
}
|
||||
|
||||
// Let the connection work with 'conn_db' or 'database'
|
||||
$params->conn_db = ( ! isset($params->database))
|
||||
? @$params->conn_db
|
||||
: @$params->database;
|
||||
if (isset($params->database))
|
||||
{
|
||||
$params->conn_db = $params->database;
|
||||
}
|
||||
|
||||
|
||||
$params->type = strtolower($params->type);
|
||||
$dbtype = ($params->type !== 'postgresql') ? $params->type : 'pgsql';
|
||||
@ -213,6 +209,7 @@ class Query_Builder {
|
||||
$this->db = new $dbtype($dsn);
|
||||
}
|
||||
|
||||
// Set the connection name property, if applicable
|
||||
if (isset($params->name))
|
||||
{
|
||||
$this->conn_name = $params->name;
|
||||
|
@ -25,10 +25,10 @@ class MySQLTest extends DBTest {
|
||||
// Attempt to connect, if there is a test config file
|
||||
if (is_file(QBASE_DIR . "test_config.json"))
|
||||
{
|
||||
$params = json_decode(file_get_contents(QBASE_DIR . "test_config.json"));
|
||||
$params = $params->mysql;
|
||||
$params = json_decode(file_get_contents(QBASE_DIR . "test_config.json"), TRUE);
|
||||
$params = $params['mysql'];
|
||||
|
||||
$this->db = new MySQL("host={$params->host};port={$params->port};dbname={$params->database}", $params->user, $params->pass);
|
||||
$this->db = new MySQL("host={$params['host']};port={$params['port']};dbname={$params['database']}", $params['user'], $params['pass']);
|
||||
}
|
||||
elseif (($var = getenv('CI')))
|
||||
{
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user