コード例 #1
0
 /**
  * 完成事务,根据查询是否出错决定是提交事务还是回滚事务
  *
  * 如果 $commitOnNoErrors 参数为 true,当事务中所有查询都成功完成时,则提交事务,否则回滚事务
  * 如果 $commitOnNoErrors 参数为 false,则强制回滚事务
  *
  * @param  $commitOnNoErrors 指示在没有错误时是否提交事务
  */
 function completeTrans($commitOnNoErrors = true)
 {
     if ($this->_transCount < 1) {
         return;
     }
     if ($this->_transCount > 1) {
         $this->_transCount -= 1;
         return;
     }
     $this->_transCount = 0;
     if ($this->_transCommit && $commitOnNoErrors) {
         $this->conn->commit();
     } else {
         $this->conn->rollBack();
     }
 }
コード例 #2
0
 /**
  * Destroys the given Token object, by invalidating and removing it from the backend.
  * @access public
  * @param mixed $token Token object.
  * @return boolean True if succesful, false if the Token could not be destroyed.
  */
 public function destroyToken($token)
 {
     if (!$token instanceof Token) {
         return false;
     }
     if (empty($token->username) || empty($token->valid_until) || empty($token->hash)) {
         return false;
     }
     $this->connection->beginTransaction();
     $stat = $this->connection->prepare(sprintf("DELETE FROM `%s` WHERE token_hash = :hash;", PowerDnsConfig::DB_TOKEN_TABLE));
     if ($stat->execute(array(":hash" => $token->hash)) === false) {
         $this->connection->rollback();
         return false;
     } else {
         $this->connection->commit();
         return true;
     }
 }
コード例 #3
0
ファイル: securimage.php プロジェクト: arunrajthala/leapers
 protected function createDatabaseTables()
 {
     $queries = array();
     switch ($this->database_driver) {
         case self::SI_DRIVER_SQLITE3:
             $queries[] = "CREATE TABLE \"{$this->database_table}\" (\n                                id VARCHAR(40),\n                                namespace VARCHAR(32) NOT NULL,\n                                code VARCHAR(32) NOT NULL,\n                                code_display VARCHAR(32) NOT NULL,\n                                created INTEGER NOT NULL,\n                                PRIMARY KEY(id, namespace)\n                              )";
             $queries[] = "CREATE INDEX ndx_created ON {$this->database_table} (created)";
             break;
         case self::SI_DRIVER_MYSQL:
             $queries[] = "CREATE TABLE `{$this->database_table}` (\n                                `id` VARCHAR(40) NOT NULL,\n                                `namespace` VARCHAR(32) NOT NULL,\n                                `code` VARCHAR(32) NOT NULL,\n                                `code_display` VARCHAR(32) NOT NULL,\n                                `created` INT NOT NULL,\n                                PRIMARY KEY(id, namespace),\n                                INDEX(created)\n                              )";
             break;
         case self::SI_DRIVER_PGSQL:
             $queries[] = "CREATE TABLE {$this->database_table} (\n                                id character varying(40) NOT NULL,\n                                namespace character varying(32) NOT NULL,\n                                code character varying(32) NOT NULL,\n                                code_display character varying(32) NOT NULL,\n                                created integer NOT NULL,\n                                CONSTRAINT pkey_id_namespace PRIMARY KEY (id, namespace)\n                              )";
             $queries[] = "CREATE INDEX ndx_created ON {$this->database_table} (created);";
             break;
     }
     $this->pdo_conn->beginTransaction();
     foreach ($queries as $query) {
         $result = $this->pdo_conn->query($query);
         if (!$result) {
             $err = $this->pdo_conn->errorInfo();
             trigger_error("Failed to create table.  {$err[1]}: {$err[2]}", E_USER_WARNING);
             $this->pdo_conn->rollBack();
             $this->pdo_conn = false;
             return false;
         }
     }
     $this->pdo_conn->commit();
     return true;
 }
コード例 #4
0
ファイル: Engine.class.php プロジェクト: happyxlq/pd
 /**
  * Commits a transaction
  *
  * @return bool
  */
 public function commit()
 {
     return $this->_conn->commit();
 }
コード例 #5
0
ファイル: abstract.class.php プロジェクト: nyroDev/nyroFwk
 /**
  * Commit a transaction.
  */
 protected function _commit()
 {
     $this->_connect();
     $this->connection->commit();
 }