function __construct() { parent::__construct(); // Get CI instance to obtain DB settings $ci =& get_instance(); $this->addConnection(array('driver' => 'mysql', 'host' => $ci->db->hostname, 'database' => $ci->db->database, 'username' => $ci->db->username, 'password' => $ci->db->password, 'charset' => $ci->db->char_set, 'collation' => $ci->db->dbcollat, 'prefix' => $ci->db->dbprefix)); // Listen to Model related events (saving, saved, updating, updated, creating, created etc). $this->setEventDispatcher(new Dispatcher(new Container())); // For CI Profiler (debugging utility) $events = new Dispatcher(); $events->listen('illuminate.query', function ($query, $bindings, $time, $name) { // Format binding data for sql insertion foreach ($bindings as $i => $binding) { if ($binding instanceof \DateTime) { $bindings[$i] = $binding->format('\'Y-m-d H:i:s\''); } else { if (is_string($binding)) { $bindings[$i] = "'{$binding}'"; } } } // Insert bindings into query $query = str_replace(array('%', '?'), array('%%', '%s'), $query); $query = vsprintf($query, $bindings); // Add it into CodeIgniter $ci =& get_instance(); $ci->db->query_times[] = $time; $ci->db->queries[] = $query; }); $this->setEventDispatcher($events); $this->setAsGlobal(); $this->bootEloquent(); }
public function __construct($config = []) { parent::__construct(); foreach ($config as $name => $value) { $this->{$name} = $value; } $this->init(); }
/** * Database manager constructor. * * @param array $settings */ public function __construct($settings = []) { parent::__construct(); $this->addConnection($settings); // Make this Capsule instance available globally via static methods $this->setAsGlobal(); // Setup the Eloquent ORM $this->bootEloquent(); }
public function __construct() { parent::__construct(); $databaseType = Configure::get('database', 'type'); $database = Configure::get('database', $databaseType); $database['driver'] = $databaseType; $this->addConnection($database); $this->setAsGlobal(); $this->bootEloquent(); }
/** * * @param string $connection * @param string $table */ public function __construct($connection, $table) { parent::__construct(); }
public function __construct($container) { parent::__construct($container); $this->bootEloquent(); }