/** * Allows the application to load a custom or default database driver. * * @param JDatabaseDriver $driver An optional database driver object. If omitted, the application driver is created. * * @return JApplicationBase This method is chainable. * * @since 12.1 */ public function loadDatabase(JDatabaseDriver $driver = null) { if ($driver === null) { $this->db = JDatabaseDriver::getInstance(array('driver' => $this->get('db_driver'), 'host' => $this->get('db_host'), 'user' => $this->get('db_user'), 'password' => $this->get('db_pass'), 'database' => $this->get('db_name'), 'prefix' => $this->get('db_prefix'))); // Select the database. $this->db->select($this->get('db_name')); } else { $this->db = $driver; } // Set the database to our static cache. JFactory::$database = $this->db; return $this; }
/** * Method to create a database driver for the Web application. * * @return void * * @since 1.0 */ protected function loadDatabase() { $database = 'sqlite' == $this->get('db_driver') ? APP_PATH_DATA . '/' . $this->get('db_name') : $this->get('db_name'); $this->db = JDatabaseDriver::getInstance(array('driver' => $this->get('db_driver'), 'host' => $this->get('db_host'), 'user' => $this->get('db_user'), 'password' => $this->get('db_pass'), 'database' => $database, 'prefix' => $this->get('db_prefix'))); // Select the database. if ('sqlite' != $this->get('db_driver')) { $this->db->select($this->get('db_name')); } // Set the debug flag. $this->db->setDebug($this->get('debug')); // Set the database to our static cache. JFactory::$database = $this->db; }