<?php
class dbLayer
{
//connection from here
private $done;
function __construct(PDO $connection)
{
$this->done = $connection;
}
public function createAction()
{
//create a new item
}
public function readAction()
{
//read all the items
}
public function updateAction()
{
$sql = $this->done->prepare("UPDATE `sync_log` SET `Sync_Status`=? WHERE `randKey`=?");
$sql->execute(array(
$status,
$randKey
));
}
public function deleteAction()
{
//delete a item
}
}
?>
我想$pdo->beginTransaction();
与类方法一起使用。如果我的更新因updateAction()
方法失败,我如何使用 roalback() ?