本文整理汇总了PHP中resource::beginTransaction方法的典型用法代码示例。如果您正苦于以下问题:PHP resource::beginTransaction方法的具体用法?PHP resource::beginTransaction怎么用?PHP resource::beginTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resource
的用法示例。
在下文中一共展示了resource::beginTransaction方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: startTrans
/**
* 启动事务
*/
function startTrans()
{
$this->_transCount += 1;
try {
$this->conn->rollBack();
} catch (PDOException $e) {
}
$this->conn->beginTransaction();
}
示例2: destroyToken
/**
* 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: createDatabaseTables
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: beginTransaction
/**
* Initiates a transaction
*
* @return bool
*/
public function beginTransaction()
{
return $this->_conn->beginTransaction();
}
示例5: _beginTransaction
/**
* Begin a transaction.
*/
protected function _beginTransaction()
{
$this->_connect();
$this->connection->beginTransaction();
}