本文整理汇总了PHP中LogModel::EndTransaction方法的典型用法代码示例。如果您正苦于以下问题:PHP LogModel::EndTransaction方法的具体用法?PHP LogModel::EndTransaction怎么用?PHP LogModel::EndTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogModel
的用法示例。
在下文中一共展示了LogModel::EndTransaction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* Delete a discussion. Update and/or delete all related data.
*
* Events: DeleteDiscussion.
*
* @since 2.0.0
* @access public
*
* @param int $DiscussionID Unique ID of discussion to delete.
* @return bool Always returns TRUE.
*/
public function delete($DiscussionID, $Options = array())
{
// 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');
// Execute deletion of discussion and related bits
$this->SQL->delete('Draft', array('DiscussionID' => $DiscussionID));
$Log = val('Log', $Options, true);
$LogOptions = val('LogOptions', $Options, array());
if ($Log === true) {
$Log = 'Delete';
}
LogModel::BeginTransaction();
// Log all of the comment deletes.
$Comments = $this->SQL->getWhere('Comment', array('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', array('DiscussionID' => $DiscussionID));
$this->SQL->delete('Discussion', array('DiscussionID' => $DiscussionID));
$this->SQL->delete('UserDiscussion', array('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;
}