Exemplo n.º 1
0
	/**
	 * Executes a prepared statement.
	 * 
	 * @param	array		$parameters
	 */
	public function executeUnbuffered(array $parameters = array()) {
		$this->parameters = $parameters;
		$this->database->incrementQueryCount();
		
		try {
			if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->start($this->query, Benchmark::TYPE_SQL_QUERY);
			
			if (empty($parameters)) $this->pdoStatement->execute();
			else $this->pdoStatement->execute($parameters);
			
			if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->stop();
		}
		catch (\PDOException $e) {
			throw new DatabaseException('Could not execute prepared statement: '.$e->getMessage(), $this->database, $this);
		}
	}
Exemplo n.º 2
0
 /**
  * Rolls back a transaction and returns true if the rollback was successfull.
  * 
  * @return	boolean
  */
 public function rollBackTransaction()
 {
     if ($this->activeTransactions === 0) {
         return false;
     }
     try {
         $this->activeTransactions--;
         if ($this->activeTransactions === 0) {
             if (WCF::benchmarkIsEnabled()) {
                 Benchmark::getInstance()->start("ROLLBACK", Benchmark::TYPE_SQL_QUERY);
             }
             $result = $this->pdo->rollback();
         } else {
             if (WCF::benchmarkIsEnabled()) {
                 Benchmark::getInstance()->start("ROLLBACK TO SAVEPOINT level" . $this->activeTransactions, Benchmark::TYPE_SQL_QUERY);
             }
             $result = $this->pdo->exec("ROLLBACK TO SAVEPOINT level" . $this->activeTransactions) !== false;
         }
         if (WCF::benchmarkIsEnabled()) {
             Benchmark::getInstance()->stop();
         }
         return $result;
     } catch (\PDOException $e) {
         throw new DatabaseException("Cannot rollback transaction: " . $e->getMessage(), $this);
     }
 }