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