/** * Open connect to database after model start construct * * @param null $db */ public function __construct($db = null) { if ($db) { // Set the instance or name $this->_db = $db; } elseif (!$this->_db) { // Use the default name $this->_db = Database::$default; } $config = Config::load('database', true); $this->_config = $config[$this->_db]; $this->_config['path'] = $config['path']; if (is_string($this->_db)) { // Load the database $this->db = Database::init($this->_db); } }