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


PHP CategoryModel::GetWhere方法代码示例

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


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

示例1: DeleteUserData

 /**
  * Delete all of the Vanilla related information for a specific user.
  * @param int $UserID The ID of the user to delete.
  * @param array $Options An array of options:
  *  - DeleteMethod: One of delete, wipe, or NULL
  * @since 2.1
  */
 public function DeleteUserData($UserID, $Options = array(), &$Data = NULL)
 {
     $SQL = Gdn::SQL();
     // Remove discussion watch records and drafts.
     $SQL->Delete('UserDiscussion', array('UserID' => $UserID));
     Gdn::UserModel()->GetDelete('Draft', array('InsertUserID' => $UserID), $Data);
     // Comment deletion depends on method selected
     $DeleteMethod = GetValue('DeleteMethod', $Options, 'delete');
     if ($DeleteMethod == 'delete') {
         // Clear out the last posts to the categories.
         $SQL->Update('Category c')->Join('Discussion d', 'd.DiscussionID = c.LastDiscussionID')->Where('d.InsertUserID', $UserID)->Set('c.LastDiscussionID', NULL)->Set('c.LastCommentID', NULL)->Put();
         $SQL->Update('Category c')->Join('Comment d', 'd.CommentID = c.LastCommentID')->Where('d.InsertUserID', $UserID)->Set('c.LastDiscussionID', NULL)->Set('c.LastCommentID', NULL)->Put();
         // Grab all of the discussions that the user has engaged in.
         $DiscussionIDs = $SQL->Select('DiscussionID')->From('Comment')->Where('InsertUserID', $UserID)->GroupBy('DiscussionID')->Get()->ResultArray();
         $DiscussionIDs = ConsolidateArrayValuesByKey($DiscussionIDs, 'DiscussionID');
         Gdn::UserModel()->GetDelete('Comment', array('InsertUserID' => $UserID), $Data);
         // Update the comment counts.
         $CommentCounts = $SQL->Select('DiscussionID')->Select('CommentID', 'count', 'CountComments')->Select('CommentID', 'max', 'LastCommentID')->WhereIn('DiscussionID', $DiscussionIDs)->GroupBy('DiscussionID')->Get('Comment')->ResultArray();
         foreach ($CommentCounts as $Row) {
             $SQL->Put('Discussion', array('CountComments' => $Row['CountComments'] + 1, 'LastCommentID' => $Row['LastCommentID']), array('DiscussionID' => $Row['DiscussionID']));
         }
         // Update the last user IDs.
         $SQL->Update('Discussion d')->Join('Comment c', 'd.LastCommentID = c.CommentID', 'left')->Set('d.LastCommentUserID', 'c.InsertUserID', FALSE, FALSE)->Set('d.DateLastComment', 'c.DateInserted', FALSE, FALSE)->WhereIn('d.DiscussionID', $DiscussionIDs)->Put();
         // Update the last posts.
         $Discussions = $SQL->WhereIn('DiscussionID', $DiscussionIDs)->Where('LastCommentUserID', $UserID)->Get('Discussion');
         // Delete the user's dicussions
         Gdn::UserModel()->GetDelete('Discussion', array('InsertUserID' => $UserID), $Data);
         // Update the appropriat recent posts in the categories.
         $CategoryModel = new CategoryModel();
         $Categories = $CategoryModel->GetWhere(array('LastDiscussionID' => NULL))->ResultArray();
         foreach ($Categories as $Category) {
             $CategoryModel->SetRecentPost($Category['CategoryID']);
         }
     } else {
         if ($DeleteMethod == 'wipe') {
             // Erase the user's dicussions
             $SQL->Update('Discussion')->Set('Body', T('The user and all related content has been deleted.'))->Set('Format', 'Deleted')->Where('InsertUserID', $UserID)->Put();
             // Erase the user's comments
             $SQL->From('Comment')->Join('Discussion d', 'c.DiscussionID = d.DiscussionID')->Delete('Comment c', array('d.InsertUserID' => $UserID));
             $SQL->Update('Comment')->Set('Body', T('The user and all related content has been deleted.'))->Set('Format', 'Deleted')->Where('InsertUserID', $UserID)->Put();
         } else {
             // Leave comments
         }
     }
     // Remove the user's profile information related to this application
     $SQL->Update('User')->Set(array('CountDiscussions' => 0, 'CountUnreadDiscussions' => 0, 'CountComments' => 0, 'CountDrafts' => 0, 'CountBookmarks' => 0))->Where('UserID', $UserID)->Put();
 }
开发者ID:remobjects,项目名称:Garden,代码行数:54,代码来源:class.hooks.php

示例2: ParseFile

 /**
  * Parse apart a doc file into its code, name, and body.
  *
  * @param $Path string System file path.
  */
 public function ParseFile($Path)
 {
     // Only parse Markdown files
     if (pathinfo($Path, PATHINFO_EXTENSION) != 'md') {
         return;
     }
     // Name
     $Name = pathinfo($Path, PATHINFO_FILENAME);
     // Code is the first line & it does not go in doc
     $Text = file_get_contents($Path);
     $Parts = explode("\n", $Text);
     $Code = $Parts[0];
     unset($Parts);
     $Text = str_replace($Code . "\n", '', $Text);
     // Category is determined by the folder it's in
     $Directory = pathinfo($Path, PATHINFO_DIRNAME);
     $FolderCode = file_get_contents($Directory . '/config');
     $CategoryModel = new CategoryModel();
     $Category = $CategoryModel->GetWhere(array('FolderCode' => $FolderCode))->FirstRow();
     $CategoryID = GetValue('CategoryID', $Category, 1);
     $this->SyncDocDiscussion($Code, $Name, $Text, $CategoryID);
     return $Code;
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:28,代码来源:class.vanilladocs.plugin.php

示例3: filenameRedirect

 /**
  *
  *
  * @param $Filename
  * @param $Get
  * @return bool|string
  */
 public function filenameRedirect($Filename, $Get)
 {
     trace(['Filename' => $Filename, 'Get' => $Get], 'Testing');
     $Filename = strtolower($Filename);
     array_change_key_case($Get);
     if (!isset(self::$Files[$Filename])) {
         return false;
     }
     $Row = self::$Files[$Filename];
     if (is_callable($Row)) {
         // Use a callback to determine the translation.
         $Row = call_user_func_array($Row, [&$Get]);
     }
     trace($Get, 'New Get');
     // Translate all of the get parameters into new parameters.
     $Vars = array();
     foreach ($Get as $Key => $Value) {
         if (!isset($Row[$Key])) {
             continue;
         }
         $Opts = (array) $Row[$Key];
         if (isset($Opts['Filter'])) {
             // Call the filter function to change the value.
             $R = call_user_func($Opts['Filter'], $Value, $Opts[0]);
             if (is_array($R)) {
                 if (isset($R[0])) {
                     // The filter can change the column name too.
                     $Opts[0] = $R[0];
                     $Value = $R[1];
                 } else {
                     // The filter can return return other variables too.
                     $Vars = array_merge($Vars, $R);
                     $Value = null;
                 }
             } else {
                 $Value = $R;
             }
         }
         if ($Value !== null) {
             $Vars[$Opts[0]] = $Value;
         }
     }
     trace($Vars, 'Translated Arguments');
     // Now let's see what kind of record we have.
     // We'll check the various primary keys in order of importance.
     $Result = false;
     if (isset($Vars['CommentID'])) {
         trace("Looking up comment {$Vars['CommentID']}.");
         $CommentModel = new CommentModel();
         // If a legacy slug is provided (assigned during a merge), attempt to lookup the comment using it
         if (isset($Get['legacy']) && Gdn::Structure()->Table('Comment')->ColumnExists('ForeignID')) {
             $Comment = $CommentModel->GetWhere(['ForeignID' => $Get['legacy'] . '-' . $Vars['CommentID']])->FirstRow();
         } else {
             $Comment = $CommentModel->GetID($Vars['CommentID']);
         }
         if ($Comment) {
             $Result = CommentUrl($Comment, '//');
         }
     } elseif (isset($Vars['DiscussionID'])) {
         trace("Looking up discussion {$Vars['DiscussionID']}.");
         $DiscussionModel = new DiscussionModel();
         $DiscussionID = $Vars['DiscussionID'];
         $Discussion = false;
         if (is_numeric($DiscussionID)) {
             // If a legacy slug is provided (assigned during a merge), attempt to lookup the discussion using it
             if (isset($Get['legacy']) && Gdn::Structure()->Table('Discussion')->ColumnExists('ForeignID')) {
                 $Discussion = $DiscussionModel->GetWhere(['ForeignID' => $Get['legacy'] . '-' . $DiscussionID])->FirstRow();
             } else {
                 $Discussion = $DiscussionModel->GetID($Vars['DiscussionID']);
             }
         } else {
             // This is a slug style discussion ID. Let's see if there is a UrlCode column in the discussion table.
             $DiscussionModel->DefineSchema();
             if ($DiscussionModel->Schema->FieldExists('Discussion', 'UrlCode')) {
                 $Discussion = $DiscussionModel->GetWhere(['UrlCode' => $DiscussionID])->FirstRow();
             }
         }
         if ($Discussion) {
             $Result = DiscussionUrl($Discussion, self::pageNumber($Vars, 'Vanilla.Comments.PerPage'), '//');
         }
     } elseif (isset($Vars['UserID'])) {
         trace("Looking up user {$Vars['UserID']}.");
         $User = Gdn::UserModel()->GetID($Vars['UserID']);
         if ($User) {
             $Result = Url(UserUrl($User), '//');
         }
     } elseif (isset($Vars['TagID'])) {
         $Tag = TagModel::instance()->GetID($Vars['TagID']);
         if ($Tag) {
             $Result = TagUrl($Tag, self::pageNumber($Vars, 'Vanilla.Discussions.PerPage'), '//');
         }
     } elseif (isset($Vars['CategoryID'])) {
         trace("Looking up category {$Vars['CategoryID']}.");
//.........这里部分代码省略.........
开发者ID:vanilla,项目名称:addons,代码行数:101,代码来源:class.redirector.plugin.php


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