blob: 86f7efd542ba358f370f9b239edf34941e46af59 [file] [log] [blame]
Taufan Adityaf4c6c9b2012-04-04 23:24:09 +07001<?php
2
3class Mock_Database_DB_Driver extends CI_DB_driver {
Andrey Andreevf243ce12012-06-09 23:34:21 +03004
Taufan Adityaf4c6c9b2012-04-04 23:24:09 +07005 /**
6 * @var object The actual Driver
7 */
8 protected $ci_db_driver;
9
10 /**
11 * Instantiate the database driver
12 *
13 * @param string DB Driver class name
14 * @param array DB configuration to set
15 * @return void
16 */
17 public function __construct($driver_class, $config = array())
18 {
Andrey Andreevf243ce12012-06-09 23:34:21 +030019 if (is_string($driver_class))
20 {
21 $this->ci_db_driver = new $driver_class($config);
22 }
Taufan Adityaf4c6c9b2012-04-04 23:24:09 +070023 }
24
25 /**
26 * Overloading method, emulate the actual driver method (multiple inheritance workaround)
27 */
28 public function __call($method, $arguments)
29 {
30 if ( ! is_callable(array($this->ci_db_driver, $method)))
31 {
32 throw new BadMethodCallException($method. ' not exists or not implemented');
33 }
34
35 return call_user_func_array(array($this->ci_db_driver, $method), $arguments);
36 }
Andrey Andreeva287a342012-11-05 23:19:59 +020037
Taufan Adityaf4c6c9b2012-04-04 23:24:09 +070038}
39
Andrey Andreev10e7a322014-02-20 16:42:16 +020040class CI_DB extends CI_DB_query_builder {}