本文整理汇总了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');