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


PHP Gdn_DataSet::importDataset方法代码示例

本文整理汇总了PHP中Gdn_DataSet::importDataset方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_DataSet::importDataset方法的具体用法?PHP Gdn_DataSet::importDataset怎么用?PHP Gdn_DataSet::importDataset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gdn_DataSet的用法示例。


在下文中一共展示了Gdn_DataSet::importDataset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cacheAttachedMedia

 /**
  * Called to prepare data grab, and then cache the results on the software level for the request.
  *
  * This will call PreloadDiscussionMedia, which will either query the db, or query memcached.
  *
  * @param mixed $Sender
  */
 protected function cacheAttachedMedia($Sender)
 {
     if ($Sender->data('Conversation')) {
         $ConversationMessageIDList = $this->getConversationMessageIDList(val('ConversationID', $Sender->data('Conversation')));
         if (count($ConversationMessageIDList)) {
             $MediaData = $this->preloadDiscussionMedia(val('ConversationID', $Sender->data('Conversation')), $ConversationMessageIDList, 'conversation');
         }
         $this->mediaCache = $MediaData;
         return;
     }
     if ($Sender->data('Messages')) {
         $Message = $Sender->data('Messages')->result();
         $MessageID = val(0, $Message)->MessageID;
         $MessageIDList = array($MessageID);
         if (count($MessageIDList)) {
             $MediaData = $this->preloadDiscussionMedia(val('ConversationID', $Sender->data('Messages')), $MessageIDList, 'conversation');
         }
         $this->mediaCache = $MediaData;
         return;
     }
     $DiscussionID = null;
     $Comments = $Sender->data('Comments');
     if ($answers = $Sender->data('Answers')) {
         $commentsArray = $Comments->resultObject();
         $commentsArray = array_merge($answers, $commentsArray);
         $commentsData = new Gdn_DataSet();
         $commentsData->importDataset($commentsArray);
         $Comments = $commentsData;
     }
     $CommentIDList = array();
     $MediaData = array();
     if ($Sender->data('Discussion.DiscussionID')) {
         $DiscussionID = $Sender->data('Discussion.DiscussionID');
     }
     if (is_null($DiscussionID) && !empty($Comments)) {
         $DiscussionID = $Comments->firstRow()->DiscussionID;
     }
     if ($DiscussionID) {
         if ($Comments instanceof Gdn_DataSet && $Comments->numRows()) {
             $Comments->dataSeek(-1);
             while ($Comment = $Comments->nextRow()) {
                 $CommentIDList[] = $Comment->CommentID;
             }
         } elseif (!empty($Sender->Discussion)) {
             $CommentIDList[] = $Sender->DiscussionID = $Sender->Discussion->DiscussionID;
         }
         if (isset($Sender->Comment) && isset($Sender->Comment->CommentID)) {
             $CommentIDList[] = $Sender->Comment->CommentID;
         }
         // TODO
         // Added note for caching here because it was the CommentIDList that is the main problem.
         // Note about memcaching:
         // Main problem with this is when a new comment is posted. It will only
         // have that current comment in the list, which, after calling
         // PreloadDiscussionMedia, means it will be the only piece of data added
         // to the cache, which prevents all the rest of the comments from loading
         // their own attachments. Consider either adding to the cache when a new
         // file is uploaded, or just getting a list of all comments for a discussion.
         // This is why memcaching has been disabled for now. There are a couple
         // ways to prevent this, but they all seem unnecessary.
         if (count($CommentIDList)) {
             $MediaData = $this->preloadDiscussionMedia($DiscussionID, $CommentIDList);
         }
         $this->mediaCache = $MediaData;
     }
 }
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:73,代码来源:class.editor.plugin.php


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