本文整理汇总了PHP中LogModel::beginTransaction方法的典型用法代码示例。如果您正苦于以下问题:PHP LogModel::beginTransaction方法的具体用法?PHP LogModel::beginTransaction怎么用?PHP LogModel::beginTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogModel
的用法示例。
在下文中一共展示了LogModel::beginTransaction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteID
/**
* Delete a discussion. Update and/or delete all related data.
*
* Events: DeleteDiscussion.
*
* @param int $discussionID Unique ID of discussion to delete.
* @param array $options Additional options to control the delete behavior. Not used for discussions.
* @return bool Always returns **true**.
*/
public function deleteID($discussionID, $options = [])
{
// Retrieve the users who have bookmarked this discussion.
$BookmarkData = $this->getBookmarkUsers($discussionID);
$Data = $this->SQL->select('*')->from('Discussion')->where('DiscussionID', $discussionID)->get()->firstRow(DATASET_TYPE_ARRAY);
$UserID = false;
$CategoryID = false;
if ($Data) {
$UserID = $Data['InsertUserID'];
$CategoryID = $Data['CategoryID'];
}
// Prep and fire event
$this->EventArguments['DiscussionID'] = $discussionID;
$this->EventArguments['Discussion'] = $Data;
$this->fireEvent('DeleteDiscussion');
// Setup logging.
$Log = val('Log', $options, true);
$LogOptions = val('LogOptions', $options, []);
if ($Log === true) {
$Log = 'Delete';
}
LogModel::beginTransaction();
// Log all of the comment deletes.
$Comments = $this->SQL->getWhere('Comment', ['DiscussionID' => $discussionID])->resultArray();
if (count($Comments) > 0 && count($Comments) < 50) {
// A smaller number of comments should just be stored with the record.
$Data['_Data']['Comment'] = $Comments;
LogModel::insert($Log, 'Discussion', $Data, $LogOptions);
} else {
LogModel::insert($Log, 'Discussion', $Data, $LogOptions);
foreach ($Comments as $Comment) {
LogModel::insert($Log, 'Comment', $Comment, $LogOptions);
}
}
LogModel::endTransaction();
$this->SQL->delete('Comment', ['DiscussionID' => $discussionID]);
$this->SQL->delete('Discussion', ['DiscussionID' => $discussionID]);
$this->SQL->delete('UserDiscussion', ['DiscussionID' => $discussionID]);
$this->updateDiscussionCount($CategoryID);
// Get the user's discussion count.
$this->updateUserDiscussionCount($UserID);
// Update bookmark counts for users who had bookmarked this discussion
foreach ($BookmarkData->result() as $User) {
$this->setUserBookmarkCount($User->UserID);
}
return true;
}