Exemplo n.º 1
0
 public function getDb($db = 'web')
 {
     if (!isset($this->_db[$db])) {
         $dbConfig = $this->getDbConfig($db);
         $this->_db[$db] = Zend_Db::factory('PDO_MYSQL', $dbConfig);
         $this->_db[$db]->query('SET names UTF8');
         $this->_db[$db]->query('SET SESSION sql_mode=\'\'');
         if (Kwf_Config::getValue('debug.disableMysqlQueryCache')) {
             $this->_db[$db]->query('SET SESSION query_cache_type=0');
         }
         /**
          * lc_time_names wird hier nicht gesetzt weil man für trlKwf
          * momentan das userModel benötigt und das gibts ohne DB
          * Verbindung nicht -> Endlosschleifen gefahr.
          * lc_time_names wurde früher vermutlich im TreeCache noch benötigt
          * (z.B. bei den News Month), aber das macht jetzt das PHP, dehalb
          * ist es nicht mehr nötig dies zu setzen.
          */
         //             $this->_db[$db]->query("SET lc_time_names = '".trlKwf('en_US')."'");
         if (Kwf_Config::getValue('debug.querylog')) {
             $profiler = new Kwf_Db_Profiler(true);
             $this->_db[$db]->setProfiler($profiler);
         } else {
             if (Kwf_Config::getValue('debug.queryTimeout')) {
                 $profiler = new Kwf_Db_Profiler_Timeout(Kwf_Config::getValue('debug.queryTimeout'), true);
                 $this->_db[$db]->setProfiler($profiler);
             } else {
                 if (Kwf_Benchmark::isEnabled() || Kwf_Benchmark::isLogEnabled()) {
                     $profiler = new Kwf_Db_Profiler_Count(true);
                     $this->_db[$db]->setProfiler($profiler);
                 }
             }
         }
     }
     return $this->_db[$db];
 }