summaryrefslogtreecommitdiffstats
path: root/tests/mocks/database/db.php
diff options
context:
space:
mode:
authorTaufan Aditya <toopay@taufanaditya.com>2012-03-30 01:29:11 +0200
committerTaufan Aditya <toopay@taufanaditya.com>2012-03-30 01:29:11 +0200
commitee2f5d08c64d96b7abc7195bcd1b6a3fd67b5b42 (patch)
tree133e61f62e6213361713b8ff9b1690afb9daded2 /tests/mocks/database/db.php
parentdba9437218a5d8bedb75464b943e8f920d220a25 (diff)
Multi database setup
Diffstat (limited to 'tests/mocks/database/db.php')
-rw-r--r--tests/mocks/database/db.php35
1 files changed, 32 insertions, 3 deletions
diff --git a/tests/mocks/database/db.php b/tests/mocks/database/db.php
index 11e4a93bd..43a0d391f 100644
--- a/tests/mocks/database/db.php
+++ b/tests/mocks/database/db.php
@@ -2,6 +2,9 @@
class Mock_Database_DB {
+ /**
+ * @var array DB configuration
+ */
private $config = array();
/**
@@ -15,6 +18,12 @@ class Mock_Database_DB {
$this->config = $config;
}
+ /**
+ * Build DSN connection string for DB driver instantiate process
+ *
+ * @param string Group name
+ * @return string DSN Connection string
+ */
public function set_dsn($group = 'default')
{
if ( ! isset($this->config[$group]))
@@ -25,7 +34,7 @@ class Mock_Database_DB {
$params = array(
'dbprefix' => '',
'pconnect' => FALSE,
- 'db_debug' => TRUE,
+ 'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
@@ -33,7 +42,6 @@ class Mock_Database_DB {
'swap_pre' => '',
'autoinit' => TRUE,
'stricton' => FALSE,
- 'failover' => array()
);
$config = array_merge($this->config[$group], $params);
@@ -51,9 +59,30 @@ class Mock_Database_DB {
$other_params = array_slice($config, 6);
- return $dsn.http_build_query($other_params);
+ return $dsn.'?'.http_build_query($other_params);
}
+ /**
+ * Return a database config array
+ *
+ * @see ./config
+ * @param string Driver based configuration
+ * @return array
+ */
+ public static function config($driver)
+ {
+ $dir = realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR;
+
+ return include($dir.'config'.DIRECTORY_SEPARATOR.$driver.'.php');
+ }
+
+ /**
+ * Main DB method wrapper
+ *
+ * @param string Group or DSN string
+ * @param bool
+ * @return object
+ */
public static function DB($group, $query_builder = FALSE)
{
include_once(BASEPATH.'database/DB.php');