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


PHP CategoryModel::setCache方法代码示例

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


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

示例1: renderDefault

 function renderDefault()
 {
     $key = 'category_info_' . $this->template->id_category;
     $this->template->category = CategoryModel::getCache($key);
     if (!$this->template->category) {
         $this->template->category = CategoryModel::getFluent()->where('id_category = %i', $this->template->id_category)->fetch();
         CategoryModel::setCache($key, $this->template->category);
     }
     /*
      * META INFO
      */
     $this['header']->addTitle($this->template->category['meta_title']);
     $this['header']->setDescription($this->template->category['meta_description']);
     $this['header']->addKeywords($this->template->category['meta_keywords']);
 }
开发者ID:oaki,项目名称:demoshop,代码行数:15,代码来源:Front_EshopPresenter.php

示例2: save


//.........这里部分代码省略.........
                     $CacheKeys[] = $this->getAnnouncementCacheKey(val('CategoryID', $Fields));
                 }
                 foreach ($CacheKeys as $CacheKey) {
                     Gdn::cache()->remove($CacheKey);
                 }
                 self::serializeRow($Fields);
                 $this->SQL->put($this->Name, $Fields, array($this->PrimaryKey => $DiscussionID));
                 setValue('DiscussionID', $Fields, $DiscussionID);
                 LogModel::logChange('Edit', 'Discussion', (array) $Fields, $Stored);
                 if (val('CategoryID', $Stored) != val('CategoryID', $Fields)) {
                     $StoredCategoryID = val('CategoryID', $Stored);
                 }
             } else {
                 // Inserting.
                 if (!val('Format', $Fields) || c('Garden.ForceInputFormatter')) {
                     $Fields['Format'] = c('Garden.InputFormatter', '');
                 }
                 if (c('Vanilla.QueueNotifications')) {
                     $Fields['Notified'] = ActivityModel::SENT_PENDING;
                 }
                 // Check for approval
                 $ApprovalRequired = checkRestriction('Vanilla.Approval.Require');
                 if ($ApprovalRequired && !val('Verified', Gdn::session()->User)) {
                     LogModel::insert('Pending', 'Discussion', $Fields);
                     return UNAPPROVED;
                 }
                 // Create discussion
                 $this->serializeRow($Fields);
                 $DiscussionID = $this->SQL->insert($this->Name, $Fields);
                 $Fields['DiscussionID'] = $DiscussionID;
                 // Update the cache.
                 if ($DiscussionID && Gdn::cache()->activeEnabled()) {
                     $CategoryCache = array('LastDiscussionID' => $DiscussionID, 'LastCommentID' => null, 'LastTitle' => Gdn_Format::text($Fields['Name']), 'LastUserID' => $Fields['InsertUserID'], 'LastDateInserted' => $Fields['DateInserted'], 'LastUrl' => DiscussionUrl($Fields));
                     CategoryModel::setCache($Fields['CategoryID'], $CategoryCache);
                     // Clear the cache if necessary.
                     if (val('Announce', $Fields)) {
                         Gdn::cache()->remove($this->getAnnouncementCacheKey(val('CategoryID', $Fields)));
                         if (val('Announce', $Fields) == 1) {
                             Gdn::cache()->remove($this->getAnnouncementCacheKey());
                         }
                     }
                 }
                 // Update the user's discussion count.
                 $InsertUser = Gdn::userModel()->getID($Fields['InsertUserID']);
                 $this->updateUserDiscussionCount($Fields['InsertUserID'], val('CountDiscussions', $InsertUser, 0) > 100);
                 // Mark the user as participated.
                 $this->SQL->replace('UserDiscussion', array('Participated' => 1), array('DiscussionID' => $DiscussionID, 'UserID' => val('InsertUserID', $Fields)));
                 // Assign the new DiscussionID to the comment before saving.
                 $FormPostValues['IsNewDiscussion'] = true;
                 $FormPostValues['DiscussionID'] = $DiscussionID;
                 // Do data prep.
                 $DiscussionName = val('Name', $Fields, '');
                 $Story = val('Body', $Fields, '');
                 $NotifiedUsers = array();
                 $UserModel = Gdn::userModel();
                 $ActivityModel = new ActivityModel();
                 if (val('Type', $FormPostValues)) {
                     $Code = 'HeadlineFormat.Discussion.' . $FormPostValues['Type'];
                 } else {
                     $Code = 'HeadlineFormat.Discussion';
                 }
                 $HeadlineFormat = t($Code, '{ActivityUserID,user} started a new discussion: <a href="{Url,html}">{Data.Name,text}</a>');
                 $Category = CategoryModel::categories(val('CategoryID', $Fields));
                 $Activity = array('ActivityType' => 'Discussion', 'ActivityUserID' => $Fields['InsertUserID'], 'HeadlineFormat' => $HeadlineFormat, 'RecordType' => 'Discussion', 'RecordID' => $DiscussionID, 'Route' => DiscussionUrl($Fields), 'Data' => array('Name' => $DiscussionName, 'Category' => val('Name', $Category)));
                 // Allow simple fulltext notifications
                 if (c('Vanilla.Activity.ShowDiscussionBody', false)) {
开发者ID:RodSloan,项目名称:vanilla,代码行数:67,代码来源:class.discussionmodel.php

示例3: incrementNewDiscussion

 /**
  * @param int|array|stdClass $Discussion The discussion ID or discussion.
  * @throws Exception
  */
 public function incrementNewDiscussion($Discussion)
 {
     if (is_numeric($Discussion)) {
         $Discussion = $this->getID($Discussion);
     }
     if (!$Discussion) {
         return;
     }
     $this->SQL->update('Category')->set('CountDiscussions', 'CountDiscussions + 1', false)->set('LastDiscussionID', val('DiscussionID', $Discussion))->set('LastCommentID', null)->set('LastDateInserted', val('DateInserted', $Discussion))->where('CategoryID', val('CategoryID', $Discussion))->put();
     $Category = CategoryModel::categories(val('CategoryID', $Discussion));
     if ($Category) {
         CategoryModel::setCache($Category['CategoryID'], ['CountDiscussions' => $Category['CountDiscussions'] + 1, 'LastDiscussionID' => val('DiscussionID', $Discussion), 'LastCommentID' => null, 'LastDateInserted' => val('DateInserted', $Discussion), 'LastTitle' => Gdn_Format::text(val('Name', $Discussion, t('No Title'))), 'LastUserID' => val('InsertUserID', $Discussion), 'LastDiscussionUserID' => val('InsertUserID', $Discussion), 'LastUrl' => DiscussionUrl($Discussion, false, '//') . '#latest']);
     }
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:18,代码来源:class.discussionmodel.php


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