当前位置: 首页>>代码示例>>PHP>>正文


PHP LogModel::beginTransaction方法代码示例

本文整理汇总了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;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:56,代码来源:class.discussionmodel.php


注:本文中的LogModel::beginTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。