Ejemplo n.º 1
0
 function getConnection()
 {
     if (!$this->connection) {
         $this->connection = $this->openDB();
         // Nahraj databázi
         if (filesize(self::$databasePath) === 0) {
             //$this->beginTransaction();
             $res = $this->connection->query(file_get_contents(dirname(__FILE__) . '/setupDB.sql'));
             if (!$res) {
                 throw new \Nette\InvalidStateException("Can't create SQLite3 database: " . $this->getConnection()->lastErrorMsg());
             }
             //$this->endTransaction();
         }
     }
     return $this->connection;
 }
 /**
  * If a write query is detected, hand it off to the configured write database
  * 
  * @param string $sql
  * @param int $errorLevel
  * @return \MySQLQuery
  */
 public function query($sql, $errorLevel = E_USER_ERROR)
 {
     if (in_array(strtolower(substr($sql, 0, strpos($sql, ' '))), $this->writeQueries) || $this->writePerformed) {
         $alternateReturn = $this->writeDb()->query($sql, $errorLevel);
         $this->writePerformed = true;
         return $alternateReturn;
     }
     if (stripos($sql, 'content')) {
         $o = 1;
     }
     return parent::query($sql, $errorLevel);
 }