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


PHP Gdn::SQL方法代码示例

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


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

示例1: BuildCategorySiteMap

 public function BuildCategorySiteMap($UrlCode, &$Urls)
 {
     $Category = CategoryModel::Categories($UrlCode);
     if (!$Category) {
         throw NotFoundException();
     }
     // Get the min/max dates for the sitemap.
     $Row = Gdn::SQL()->Select('DateInserted', 'min', 'MinDate')->Select('DateInserted', 'max', 'MaxDate')->From('Discussion')->Where('CategoryID', $Category['CategoryID'])->Get()->FirstRow(DATASET_TYPE_ARRAY);
     if ($Row) {
         $From = strtotime('first day of this month 00:00:00', strtotime($Row['MaxDate']));
         $To = strtotime('first day of this month 00:00:00', strtotime($Row['MinDate']));
         if (!$From || !$To) {
             $From = -1;
             $To = 0;
         }
     } else {
         $From = -1;
         $To = 0;
     }
     $Now = time();
     for ($i = $From; $i >= $To; $i = strtotime('-1 month', $i)) {
         $Url = array('Loc' => Url('/categories/archives/' . rawurlencode($Category['UrlCode'] ? $Category['UrlCode'] : $Category['CategoryID']) . '/' . gmdate('Y-m', $i), TRUE), 'LastMod' => '', 'ChangeFreq' => '');
         $LastMod = strtotime('last day of this month', $i);
         if ($LastMod > $Now) {
             $LastMod = $Now;
         }
         $Url['LastMod'] = gmdate('c', $LastMod);
         $Urls[] = $Url;
     }
     // If there are no links then just link to the category.
     if (count($Urls) === 0) {
         $Url = array('Loc' => CategoryUrl($Category), 'LastMode' => '', 'ChangeFreq' => '');
         $Urls[] = $Url;
     }
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:35,代码来源:class.sitemaps.plugin.php

示例2: _GenerateConfContent

 private function _GenerateConfContent($Template)
 {
     $SQLSock = '';
     if ('' != trim(ini_get('mysql.default_socket'))) {
         $SQLSock = 'sql_sock = ' . ini_get('mysql.default_socket');
     }
     //Check to see if grabing any of the tags
     ///@todo fix this stopgap solution with something more robust
     //Get list of tags
     $SQL = Gdn::SQL();
     if (Gdn::Structure()->TableExists('TagDiscussion')) {
         $Tags = TRUE;
     } else {
         $Tags = FALSE;
     }
     $DBPrefix = C('Database.Name') . '.' . C('Database.DatabasePrefix', 'GDN_');
     //join these 2
     $Search = array('{sql_sock}' => $SQLSock, '{sql_host}' => $this->Settings['Install']->Host, '{sql_user}' => C('Database.User'), '{sql_pass}' => C('Database.Password'), '{sql_db}' => C('Database.Name'), '{charset_type}' => C('Garden.Charset', 'utf-8'), '{charset_type_mysql}' => C('Database.CharacterEncoding', 'utf8'), '{install_path}' => $this->Settings['Install']->InstallPath, '{assests_path}' => PATH_PLUGINS . DS . 'SphinxSearchLite' . DS . 'assests' . DS, '{searchd_port}' => $this->Settings['Install']->Port, '{log_path}' => $this->Settings['Install']->LogPath, '{query_path}' => $this->Settings['Install']->QueryPath, '{PID_path}' => $this->Settings['Install']->PIDPath, '{data_path}' => $this->Settings['Install']->DataPath, '{db_prefix}' => $DBPrefix, '{ss_prefix}' => $this->Settings['Install']->Prefix);
     /* '{tag_select}' => $Tags == TRUE ? '(SELECT td.TagID as TagName\
        FROM '.$DBPrefix.'TagDiscussion td\
        WHERE pic.GDN_Comment.DiscussionID = td.DiscussionID),\\' : '\\',*/
     $ReWritedContent = str_replace(array_keys($Search), $Search, $Template);
     //echo nl2br($ReWritedContent); die;
     return $ReWritedContent;
 }
开发者ID:Nordic-T,项目名称:vanilla-plugins,代码行数:25,代码来源:class.sphinxsearchinstall.php

示例3: GetAll

 public function GetAll($ForeignType, $ForeignIDs = array())
 {
     if (count($ForeignIDs) == 0) {
         return new Gdn_DataSet(array());
     }
     return Gdn::SQL()->Select('*')->From('Regarding')->Where('ForeignType', $ForeignType)->WhereIn('ForeignID', $ForeignIDs)->Get();
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:7,代码来源:class.regardingmodel.php

示例4: _CacheOnlineUserss

 protected function _CacheOnlineUserss(&$Sender)
 {
     //logic taken from Who's Online plugin
     $SQL = Gdn::SQL();
     // $this->_OnlineUsers = $SQL
     // insert or update entry into table
     $Session = Gdn::Session();
     $Invisible = $Invisible ? 1 : 0;
     if ($Session->UserID) {
         $SQL->Replace('Whosonline', array('UserID' => $Session->UserID, 'Timestamp' => Gdn_Format::ToDateTime(), 'Invisible' => $Invisible), array('UserID' => $Session->UserID));
     }
     $Frequency = C('WhosOnline.Frequency', 4);
     $History = time() - $Frequency;
     $SQL->Select('u.UserID, u.Name, w.Timestamp, w.Invisible')->From('Whosonline w')->Join('User u', 'w.UserID = u.UserID')->Where('w.Timestamp >=', date('Y-m-d H:i:s', $History))->OrderBy('u.Name');
     if (!$Session->CheckPermission('Plugins.WhosOnline.ViewHidden')) {
         $SQL->Where('w.Invisible', 0);
     }
     $OnlineUsers = $SQL->Get();
     $arrOnline = array();
     if ($OnlineUsers->NumRows() > 0) {
         foreach ($OnlineUsers->Result() as $User) {
             $arrOnline[] = $User->UserID;
         }
     }
     $Sender->SetData('Plugin-OnlineUsers-Marker', $arrOnline);
 }
开发者ID:ru4,项目名称:arabbnota,代码行数:26,代码来源:class.onlineusers.plugin.php

示例5: GetData

   public function GetData($Limit = 10) {
      $this->Data = FALSE;
      if (Gdn::Session()->IsValid() && C('Vanilla.Modules.ShowBookmarkedModule', TRUE)) {
         $BookmarkIDs = Gdn::SQL()
            ->Select('DiscussionID')
            ->From('UserDiscussion')
            ->Where('UserID', Gdn::Session()->UserID)
            ->Where('Bookmarked', 1)
            ->Get()->ResultArray();
         $BookmarkIDs = ConsolidateArrayValuesByKey($BookmarkIDs, 'DiscussionID');

         if (count($BookmarkIDs)) {
            $DiscussionModel = new DiscussionModel();
            DiscussionModel::CategoryPermissions();

            $DiscussionModel->SQL->WhereIn('d.DiscussionID', $BookmarkIDs);
            
            $this->Data = $DiscussionModel->Get(
               0,
               $Limit
            );
         } else {
            $this->Data = FALSE;
         }
      }
   }
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:26,代码来源:class.bookmarkedmodule.php

示例6: GetData

 public function GetData($FingerprintUserID, $Fingerprint)
 {
     if (!Gdn::Session()->CheckPermission('Garden.Users.Edit')) {
         return;
     }
     $this->_Data = Gdn::SQL()->Select()->From('User')->Where('Fingerprint', $Fingerprint)->Where('UserID <>', $FingerprintUserID)->Get();
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:7,代码来源:class.sharedfingerprintmodule.php

示例7: GetData

 public function GetData()
 {
     $TagQuery = Gdn::SQL();
     $this->AutoContext();
     $TagCacheKey = "TagModule-{$this->ParentType}-{$this->ParentID}";
     switch ($this->ParentType) {
         case 'Discussion':
             $Tags = TagModel::instance()->getDiscussionTags($this->ParentID, false);
             break;
         case 'Category':
             $TagQuery->Join('TagDiscussion td', 't.TagID = td.TagID')->Select('COUNT(DISTINCT td.TagID)', '', 'NumTags')->Where('td.CategoryID', $this->ParentID)->GroupBy('td.TagID')->Cache($TagCacheKey, 'get', array(Gdn_Cache::FEATURE_EXPIRY => 120));
             break;
         case 'Global':
             $TagCacheKey = 'TagModule-Global';
             $TagQuery->Where('t.CountDiscussions >', 0, FALSE)->Cache($TagCacheKey, 'get', array(Gdn_Cache::FEATURE_EXPIRY => 120));
             if ($this->CategorySearch) {
                 $TagQuery->Where('t.CategoryID', '-1');
             }
             break;
     }
     if (isset($Tags)) {
         $this->_TagData = new Gdn_DataSet($Tags, DATASET_TYPE_ARRAY);
     } else {
         $this->_TagData = $TagQuery->Select('t.*')->From('Tag t')->OrderBy('t.CountDiscussions', 'desc')->Limit(25)->Get();
     }
     $this->_TagData->DatasetType(DATASET_TYPE_ARRAY);
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:27,代码来源:class.tagmodule.php

示例8: Expire

 public function Expire()
 {
     $ExpireBans = Gdn::SQL()->Select('Count(UserID)')->From('User')->Where(array('Banned' => TRUE, 'BanExpire<' => Gdn_Format::ToDateTime()))->Get()->Result();
     if ($ExpireBans) {
         Gdn::SQL()->Put('User', array('Banned' => FALSE, 'BanExpire' => NULL), array('Banned' => TRUE, 'BanExpire<' => Gdn_Format::ToDateTime()));
     }
 }
开发者ID:pawigor,项目名称:TempBan-Vanilla-Plugin,代码行数:7,代码来源:default.php

示例9: GetData

 public function GetData($DiscussionID = '')
 {
     $SQL = Gdn::SQL();
     if (is_numeric($DiscussionID) && $DiscussionID > 0) {
         $this->_DiscussionID = $DiscussionID;
         $SQL->Join('TagDiscussion td', 't.TagID = td.TagID')->Where('td.DiscussionID', $DiscussionID);
     }
     $this->_TagData = $SQL->Select('t.*')->From('Tag t')->Where('t.CountDiscussions >', 0, FALSE)->OrderBy('t.CountDiscussions', 'desc')->Limit(25)->Get();
 }
开发者ID:tautomers,项目名称:knoopvszombies,代码行数:9,代码来源:class.tagmodule.php

示例10: Structure

 public function Structure()
 {
     // Get a user for operations.
     $UserID = Gdn::SQL()->GetWhere('User', array('Name' => 'Mollom', 'Admin' => 2))->Value('UserID');
     if (!$UserID) {
         $UserID = Gdn::SQL()->Insert('User', array('Name' => 'Mollom', 'Password' => RandomString('20'), 'HashMethod' => 'Random', 'Email' => 'mollom@domain.com', 'DateInserted' => Gdn_Format::ToDateTime(), 'Admin' => '2'));
     }
     SaveToConfig('Plugins.Mollom.UserID', $UserID);
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:9,代码来源:class.mollom.plugin.php

示例11: DeleteRoute

 public static function DeleteRoute($URI, $RequestUri = Null)
 {
     $SQL = Gdn::SQL();
     $Where = array();
     if ($RequestUri !== Null) {
         $Where['RequestUri'] = $RequestUri;
     } else {
         $Where = array('URI' => $URI);
     }
     $SQL->Delete('Route', $Where);
 }
开发者ID:unlight,项目名称:Candy,代码行数:11,代码来源:class.candymodel.php

示例12: Award

 public function Award($Sender, $User, $Criteria)
 {
     $Target = $Criteria->Target;
     $TargetDate = date(DATE_ISO8601, strtotime($Criteria->Duration . ' ' . $Criteria->Period . ' ago'));
     $SQL = Gdn::SQL();
     $Count = $SQL->Select('count(CommentID) as Count')->From('Comment')->Where('InsertUserID', $User->UserID)->Where('DateInserted >=', $TargetDate)->Get()->FirstRow();
     if ($Count->Count >= $Target) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
开发者ID:hxii,项目名称:Application-Yaga,代码行数:12,代码来源:class.commentmarathon.php

示例13: DiscussionModel_GetCountParticipated_Create

 public function DiscussionModel_GetCountParticipated_Create(&$Sender)
 {
     $UserID = GetValue(0, $Sender->EventArguments);
     if (is_null($UserID)) {
         if (!Gdn::Session()->IsValid()) {
             throw new Exception(T("Could not get participated discussions for non logged-in user."));
         }
         $UserID = Gdn::Session()->UserID;
     }
     $Count = Gdn::SQL()->Select('c.DiscussionID', 'DISTINCT', 'NumDiscussions')->From('Comment c')->Where('c.InsertUserID', $UserID)->GroupBy('c.DiscussionID')->Get();
     return $Count instanceof Gdn_Dataset ? $Count->NumRows() : FALSE;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:12,代码来源:class.participated.plugin.php

示例14: GetProviderByScheme

 public function GetProviderByScheme($AuthenticationSchemeAlias, $UserID = NULL)
 {
     $ProviderQuery = Gdn::SQL()->Select('uap.*')->From('UserAuthenticationProvider uap')->Where('uap.AuthenticationSchemeAlias', $AuthenticationSchemeAlias);
     if (!is_null($UserID) && $UserID) {
         $ProviderQuery->Join('UserAuthentication ua', 'ua.ProviderKey = uap.AuthenticationKey', 'left')->Where('ua.UserID', $UserID);
     }
     $ProviderData = $ProviderQuery->Get();
     if ($ProviderData->NumRows()) {
         return $ProviderData->FirstRow(DATASET_TYPE_ARRAY);
     }
     return FALSE;
 }
开发者ID:tautomers,项目名称:knoopvszombies,代码行数:12,代码来源:class.authenticationprovidermodel.php

示例15: EntryController_Render_Before

 /**
  * @param Gdn_Controller $Sender
  * @param array $Args
  */
 public function EntryController_Render_Before($Sender, $Args)
 {
     if ($Sender->RequestMethod != 'passwordreset') {
         return;
     }
     if (isset($Sender->Data['User'])) {
         // Get all of the users with the same email.
         $Email = $Sender->Data('User.Email');
         $Users = Gdn::SQL()->Select('Name')->From('User')->Where('Email', $Email)->Get()->ResultArray();
         $Names = array_column($Users, 'Name');
         SetValue('Name', $Sender->Data['User'], implode(', ', $Names));
     }
 }
开发者ID:vanilla,项目名称:addons,代码行数:17,代码来源:class.emailpasswordsync.plugin.php


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