本文整理匯總了PHP中RedBeanPHP\R::commit方法的典型用法代碼示例。如果您正苦於以下問題:PHP R::commit方法的具體用法?PHP R::commit怎麽用?PHP R::commit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類RedBeanPHP\R
的用法示例。
在下文中一共展示了R::commit方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setQueueRowsDone
/**
* Sets multiple queue rows as done
* @param type $rows
*/
public function setQueueRowsDone($rows)
{
R::begin();
foreach ($rows as $row) {
$res = $this->setQueueRowDone($row);
if (!$res) {
return R::rollback();
}
}
return R::commit();
}
示例2: foreach
R::begin();
foreach ($data->positions as $posItem) {
$item = R::load('item', $posItem->item);
$before = $item->export();
$oldLane = $item->lane->id;
$item->lane = R::load('lane', $posItem->lane);
if ($oldLane != $item->lane->id) {
$movedItem = $item;
$beforeItem = $before;
$afterItem = $item->export();
}
$item->position = $posItem->position;
runAutoActions($item);
R::store($item);
}
R::commit();
// If an item changed lanes, log the action.
if (null != $movedItem) {
logAction($user->username . ' moved item ' . $movedItem->title . ' to lane ' . $movedItem->lane->name, $beforeItem, $afterItem, $movedItem->id);
}
$jsonResponse->addBeans(getBoards());
}
$app->response->setBody($jsonResponse->asJson());
});
// Add a comment to an item.
$app->post('/items/:itemId/comment', function ($itemId) use($app, $jsonResponse) {
$data = json_decode($app->environment['slim.input']);
if (validateToken()) {
$user = getUser();
$item = R::load('item', $itemId);
if ($item->id) {
示例3: commitBean
/**
* commit a bean with transactions
* @param object $bean
* @return $res false or last insert id
*/
public static function commitBean($bean)
{
R::begin();
try {
$res = R::store($bean);
R::commit();
} catch (Exception $e) {
R::rollback();
$res = false;
}
return $res;
}