Exemplo n.º 1
0
 protected function Query($query)
 {
     //		SPConfig::debOut( $query, false, false, true );
     switch ($this->_driver) {
         case 'SQLITE':
             try {
                 if ($r = $this->_db->query($query, SQLITE_ASSOC)) {
                     $r = $r->fetch();
                 } else {
                     Sobi::Error('cache', sprintf('SQLite error on query: %s', $query), SPC::WARNING, 0, __LINE__, __FILE__);
                     return false;
                 }
             } catch (SQLiteException $x) {
                 Sobi::Error('cache', sprintf('SQLite error: %s', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
                 $this->_enabled = false;
                 $this->cleanAll();
                 return false;
             }
             break;
         case 'PDO':
             if ($s = $this->_db->prepare($query)) {
                 $s->execute();
                 $r = $s->fetch(PDO::FETCH_ASSOC);
             } else {
                 Sobi::Error('cache', sprintf('SQLite error on query: %s. Error %s', $query, implode("\n", $this->_db->errorInfo())), SPC::WARNING, 0, __LINE__, __FILE__);
                 $this->_enabled = false;
                 $this->cleanAll();
                 return false;
             }
             break;
     }
     return $r;
 }