本文整理汇总了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;
}
}