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


PHP Gdn_Model::getWhere方法代码示例

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


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

示例1: mergeStart

 /**
  * Start merging user accounts.
  *
  * @param int $OldUserID The ID of the old user.
  * @param int $NewUserID The ID of the new user.
  * @return int|null Returns the merge table ID of the merge.
  * @throws Gdn_UserException Throws an exception of there is a data validation error.
  */
 private function mergeStart($OldUserID, $NewUserID)
 {
     $Model = new Gdn_Model('UserMerge');
     // Grab the users.
     $OldUser = $this->getID($OldUserID, DATASET_TYPE_ARRAY);
     $NewUser = $this->getID($NewUserID, DATASET_TYPE_ARRAY);
     // First see if there is a record with the same merge.
     $Row = $Model->getWhere(['OldUserID' => $OldUserID, 'NewUserID' => $NewUserID])->firstRow(DATASET_TYPE_ARRAY);
     if ($Row) {
         $MergeID = $Row['MergeID'];
         // Save this merge in the log.
         if ($Row['Attributes']) {
             $Attributes = dbdecode($Row['Attributes']);
         } else {
             $Attributes = [];
         }
         $Attributes['Log'][] = ['UserID' => Gdn::session()->UserID, 'Date' => Gdn_Format::toDateTime()];
         $Row = ['MergeID' => $MergeID, 'Attributes' => $Attributes];
     } else {
         $Row = ['OldUserID' => $OldUserID, 'NewUserID' => $NewUserID];
     }
     $UserSet = [];
     $OldUserSet = [];
     if (dateCompare($OldUser['DateFirstVisit'], $NewUser['DateFirstVisit']) < 0) {
         $UserSet['DateFirstVisit'] = $OldUser['DateFirstVisit'];
     }
     if (!isset($Row['Attributes']['User']['CountVisits'])) {
         $UserSet['CountVisits'] = $OldUser['CountVisits'] + $NewUser['CountVisits'];
         $OldUserSet['CountVisits'] = 0;
     }
     if (!empty($UserSet)) {
         // Save the user information on the merge record.
         foreach ($UserSet as $Key => $Value) {
             // Only save changed values that aren't already there from a previous merge.
             if ($NewUser[$Key] != $Value && !isset($Row['Attributes']['User'][$Key])) {
                 $Row['Attributes']['User'][$Key] = $NewUser[$Key];
             }
         }
     }
     $MergeID = $Model->save($Row);
     if (val('MergeID', $Row)) {
         $MergeID = $Row['MergeID'];
     }
     if (!$MergeID) {
         throw new Gdn_UserException($Model->Validation->resultsText());
     }
     // Update the user with the new user-level data.
     $this->setField($NewUserID, $UserSet);
     if (!empty($OldUserSet)) {
         $this->setField($OldUserID, $OldUserSet);
     }
     return $MergeID;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:61,代码来源:class.usermodel.php

示例2: preloadDiscussionMedia

 /**
  * Query the Media table for any media related to the current discussion,
  * including all the comments. This will be cached per discussion.
  *
  * @param int $discussionID
  * @param array $commentIDList
  * @return array
  */
 public function preloadDiscussionMedia($discussionID, $commentIDList, $type = 'discussion')
 {
     $mediaData = array();
     $mediaDataDiscussion = array();
     $mediaDataComment = array();
     $mediaModel = new Gdn_Model('Media');
     // Query the Media table for discussion media.
     if ($type === 'discussion') {
         if (is_numeric($discussionID)) {
             $sqlWhere = array('ForeignTable' => 'discussion', 'ForeignID' => $discussionID);
             $mediaDataDiscussion = $mediaModel->getWhere($sqlWhere)->resultArray();
         }
     }
     // Query the Media table for comment media.
     if (is_numeric($commentIDList)) {
         $commentIDList[] = $commentIDList;
     }
     if (is_array($commentIDList) && count($commentIDList)) {
         $commentIDList = array_filter($commentIDList);
         $sqlWhere = array('ForeignTable' => $type == 'discussion' ? 'comment' : 'message', 'ForeignID' => $commentIDList);
         $mediaDataComment = $mediaModel->getWhere($sqlWhere)->resultArray();
     }
     $mediaData = array_merge($mediaDataDiscussion, $mediaDataComment);
     return $mediaData;
 }
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:33,代码来源:class.editor.plugin.php

示例3: preloadDiscussionMedia

 /**
  * Query the Media table for any media related to the current discussion,
  * including all the comments. This will be cached per discussion.
  *
  * @param int $discussionID
  * @param array $commentIDList
  * @return array
  */
 public function preloadDiscussionMedia($discussionID, $commentIDList, $type = 'discussion')
 {
     $mediaData = array();
     $mediaDataDiscussion = array();
     $mediaDataComment = array();
     /*$cacheKey = sprintf(self::DISCUSSION_MEDIA_CACHE_KEY, $discussionID);
       $cacheResponse = Gdn::cache()->get($cacheKey);
       if ($cacheResponse === Gdn_Cache::CACHEOP_FAILURE) {*/
     $mediaModel = new Gdn_Model('Media');
     // Query the Media table for discussion media.
     if ($type === 'discussion') {
         if (is_numeric($discussionID)) {
             $sqlWhere = array('ForeignTable' => 'discussion', 'ForeignID' => $discussionID);
             $mediaDataDiscussion = $mediaModel->getWhere($sqlWhere)->resultArray();
         }
     }
     // Query the Media table for comment media.
     if (is_numeric($commentIDList)) {
         $commentIDList[] = $commentIDList;
     }
     if (is_array($commentIDList) && count($commentIDList)) {
         $commentIDList = array_filter($commentIDList);
         $sqlWhere = array('ForeignTable' => $type == 'discussion' ? 'comment' : 'message', 'ForeignID' => $commentIDList);
         $mediaDataComment = $mediaModel->getWhere($sqlWhere)->resultArray();
     }
     $mediaData = array_merge($mediaDataDiscussion, $mediaDataComment);
     /*
              Gdn::cache()->store($cacheKey, $mediaData, array(
                     Gdn_Cache::FEATURE_EXPIRY => $this->mediaCacheExpire
              ));
            } else {
              $mediaData = $cacheResponse;
            }*/
     return $mediaData;
 }
开发者ID:rbrahmson,项目名称:vanilla,代码行数:43,代码来源:class.editor.plugin.php

示例4: deletePicture

 /**
  * Delete a screenshot from an addon.
  *
  * @param string $AddonPictureID Picture id to remove.
  * @throws Gdn_UserException No permission to delete this picture.
  */
 public function deletePicture($AddonPictureID = '')
 {
     $AddonPictureModel = new Gdn_Model('AddonPicture');
     $Picture = $AddonPictureModel->getWhere(array('AddonPictureID' => $AddonPictureID))->firstRow();
     $AddonModel = new AddonModel();
     $Addon = $AddonModel->getID($Picture->AddonID);
     $Session = Gdn::session();
     if ($Session->UserID != $Addon['InsertUserID'] && !$Session->checkPermission('Addons.Addon.Manage')) {
         throw permissionException();
     }
     if ($this->Form->authenticatedPostBack() && $this->Form->getFormValue('Yes')) {
         if ($Picture) {
             $Upload = new Gdn_Upload();
             $Upload->delete(changeBasename($Picture->File, 'ao%s'));
             $Upload->delete(changeBasename($Picture->File, 'at%s'));
             $AddonPictureModel->delete(array('AddonPictureID' => $AddonPictureID));
         }
         $this->RedirectUrl = url('/addon/' . $Picture->AddonID);
     }
     $this->render('deletepicture');
 }
开发者ID:vanilla,项目名称:community,代码行数:27,代码来源:class.addoncontroller.php

示例5: getWhere

 /**
  * {@inheritDoc}
  * in addition; We CalculateRow for each record found (Add Attachments)
  * @see Gdn_Model::GetWhere
  */
 public function getWhere($Where = false, $OrderFields = '', $OrderDirection = 'asc', $Limit = false, $Offset = false)
 {
     $Data = parent::getWhere($Where, $OrderFields, $OrderDirection, $Limit, $Offset);
     $Rows =& $Data->resultArray();
     foreach ($Rows as &$Row) {
         $this->calculateRow($Row);
     }
     return $Data;
 }
开发者ID:R-J,项目名称:vanilla,代码行数:14,代码来源:class.attachmentmodel.php

示例6: getConversationMembers

 /**
  * Get all the members of a conversation from the $ConversationID.
  *
  * @param int $ConversationID The conversation ID.
  *
  * @return array Array of user IDs.
  */
 public function getConversationMembers($ConversationID)
 {
     $ConversationMembers = array();
     $UserConversation = new Gdn_Model('UserConversation');
     $UserMembers = $UserConversation->getWhere(array('ConversationID' => $ConversationID))->resultArray();
     if (is_array($UserMembers) && count($UserMembers)) {
         $ConversationMembers = array_column($UserMembers, 'UserID');
     }
     return $ConversationMembers;
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:17,代码来源:class.conversationsmodel.php

示例7: touch

 /**
  *
  *
  * @param $Name
  * @param $Value
  */
 public static function touch($Name, $Value)
 {
     $Model = new Gdn_Model('Pocket');
     $Pockets = $Model->getWhere(array('Name' => $Name))->resultArray();
     if (empty($Pockets)) {
         $Pocket = array('Name' => $Name, 'Location' => 'Content', 'Sort' => 0, 'Repeat' => Pocket::REPEAT_BEFORE, 'Body' => $Value, 'Format' => 'Raw', 'Disabled' => Pocket::DISABLED, 'MobileOnly' => 0, 'MobileNever' => 0, 'EmbeddedNever' => 0, 'ShowInDashboard' => 0, 'Type' => 'default');
         $Model->save($Pocket);
     }
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:15,代码来源:class.pocket.php


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