本文整理匯總了PHP中pdo::commit方法的典型用法代碼示例。如果您正苦於以下問題:PHP pdo::commit方法的具體用法?PHP pdo::commit怎麽用?PHP pdo::commit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pdo
的用法示例。
在下文中一共展示了pdo::commit方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addMessage
/**
* @method add a message to a thread.
* @param $MSG the message
* @param string subject of the message
* @param string text/body of the message
* @param date date of the message
* @param number $threadId the thread id to add msg
*/
public function addMessage($subject, $text, $date, $threadId)
{
$this->pdo->beginTransaction();
$msgId = $this->getNextVal(self::$SEQ_MSG_ID);
$sql = $this->getQuery('INSERT INTO ' . self::$SCHEMA . '.MSG ("ID", "Subject", "Text", "Date", "Thread_ID") VALUES (' . $msgId . ', ?, ?, ?, ' . $threadId . ')');
$stmt = $this->pdo->prepare($sql);
$this->executeQueryRollbackOnException($stmt, array($subject, $text, $date));
$sql = $this->getQuery('INSERT INTO ' . self::$SCHEMA . '.MSG_BOX ("MSG_ID", "To_User_ID", "From_User_ID", "Status") VALUES (' . $msgId . ', ?, ?, ?)');
$stmt = $this->pdo->prepare($sql);
$this->executeQueryRollbackOnException($stmt, array($this->getConversationPartner($threadId), $this->userId, self::$NOT_READED));
$this->pdo->commit();
}
示例2: commitTrans
/**
* 提交事務
*/
public function commitTrans()
{
$this->pdo->commit();
}
示例3: pdo
<?php
$db = new pdo('sqlite::memory:');
$db->beginTransaction();
$db->query('CREATE TABLE IF NOT EXISTS foobar (id INT AUTO INCREMENT, name TEXT)');
$db->commit();
$db->beginTransaction();
$db->query('INSERT INTO foobar VALUES (NULL, "PHP")');
$db->query('INSERT INTO foobar VALUES (NULL, "PHP6")');
$db->rollback();
$r = $db->query('SELECT COUNT(*) FROM foobar');
var_dump($r->rowCount());
$db->query('DROP TABLE foobar');