Exemple #1
0
 private function connectDB()
 {
     try {
         $dbconfig = array('host' => $this->config->database->host, 'username' => $this->config->database->username, 'password' => $this->config->database->password, 'dbname' => $this->config->database->db);
         $dbconfig = $this->doQoolHook('front_pre_connectdb', $dbconfig);
         //here we check for database type
         switch ($this->config->database->type) {
             case "mysql":
                 $db = new Zend_Db_Adapter_Pdo_Mysql($dbconfig);
                 $db->getConnection();
                 $db->setFetchMode(Zend_Db::FETCH_ASSOC);
                 $smt = $db->query("SET NAMES 'utf8'");
                 $smt->execute();
                 break;
             case "sqlite":
                 $db = new Zend_Db_Adapter_Pdo_Sqlite($dbconfig);
                 $db->getConnection();
                 $db->setFetchMode(Zend_Db::FETCH_ASSOC);
                 break;
             default:
                 $db = new Zend_Db_Adapter_Pdo_Mysql($dbconfig);
                 $db->getConnection();
                 $db->setFetchMode(Zend_Db::FETCH_ASSOC);
                 $smt = $db->query("SET NAMES 'utf8'");
                 $smt->execute();
         }
     } catch (Zend_Db_Adapter_Exception $e) {
         $this->triggerError($this->language['db_connect_error']);
     } catch (Zend_Exception $e) {
         $this->triggerError($this->language['db_factory_error']);
     }
     $db = $this->doQoolHook('front_after_connectdb', $db);
     $this->db = $db;
 }