當前位置: 首頁>>代碼示例>>PHP>>正文


PHP xPDOQuery::distinct方法代碼示例

本文整理匯總了PHP中xPDOQuery::distinct方法的典型用法代碼示例。如果您正苦於以下問題:PHP xPDOQuery::distinct方法的具體用法?PHP xPDOQuery::distinct怎麽用?PHP xPDOQuery::distinct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在xPDOQuery的用法示例。


在下文中一共展示了xPDOQuery::distinct方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: prepareQueryBeforeCount

 /**
  * Can be used to adjust the query prior to the COUNT statement
  *
  * @param xPDOQuery $c
  * @return xPDOQuery
  */
 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $props = $this->getProperties();
     $c->distinct();
     // from combobox
     if (isset($props['valuesqry'])) {
         if ($props['valuesqry'] === 'true') {
             if (isset($props['query'])) {
                 if (!empty($props['query'])) {
                     $query = urldecode($props['query']);
                     $queries = @explode('||', $query);
                     $i = 0;
                     $where = '';
                     foreach ($queries as $query) {
                         $where .= ($i !== 0 ? ' OR ' : '') . "`smarttagTags`.`tag` = '{$query}'";
                         $i++;
                     }
                     $c->where("({$where})");
                 }
             }
         } else {
             if (isset($props['query']) && !empty($props['query'])) {
                 $c->where(array('tag:LIKE' => "{$props['query']}%", 'OR:tag:LIKE' => "% {$props['query']}%"));
             }
         }
     } else {
         if (isset($props['query']) && !empty($props['query'])) {
             $c->where(array('tag:LIKE' => "%{$props['query']}%"));
         }
     }
     $tvId = isset($props['tvId']) && is_numeric($props['tvId']) ? intval($props['tvId']) : '';
     // for tagcloud
     if (strtolower($props['sort']) === 'count') {
         $c->select(array('smarttagTags.id', 'smarttagTags.tag', 'count' => "(SELECT COUNT(*) FROM {$this->modx->getTableName('smarttagTagresources')} AS Tagresources " . 'WHERE (Tagresources.tag_id = smarttagTags.id ' . (!empty($tvId) ? 'AND Tagresources.tmplvar_id=' . $tvId : '') . '))'));
         $c->sortby('count', 'desc');
         $c->sortby('tag', 'asc');
     }
     if (!empty($tvId)) {
         $tv = $this->modx->getObject('modTemplateVar', $tvId);
         if ($tv) {
             $params = $tv->get('input_properties');
             if ($params['globaltags'] != 'true') {
                 $c->leftJoin('smarttagTagresources', 'Tagresources', 'Tagresources.tag_id = smarttagTags.id');
                 $c->where(array('Tagresources.tmplvar_id' => $tvId));
             }
         }
     }
     return $c;
 }
開發者ID:ExcaliburKG,項目名稱:SmartTag,代碼行數:55,代碼來源:getlist.class.php

示例2: prepareQueryBeforeCount

 public function prepareQueryBeforeCount(xPDOQuery $c)
 {
     $c->leftJoin('modUserProfile', 'Profile');
     $query = $this->getProperty('query', '');
     if (!empty($query)) {
         $c->where(array('modUser.username:LIKE' => '%' . $query . '%', 'OR:Profile.fullname:LIKE' => '%' . $query . '%', 'OR:Profile.email:LIKE' => '%' . $query . '%'));
     }
     $userGroup = $this->getProperty('usergroup', 0);
     if (!empty($userGroup)) {
         if ($userGroup === 'anonymous') {
             $c->join('modUserGroupMember', 'UserGroupMembers', 'LEFT OUTER JOIN');
             $c->where(array('UserGroupMembers.user_group' => NULL));
         } else {
             $c->distinct();
             $c->innerJoin('modUserGroupMember', 'UserGroupMembers');
             $c->where(array('UserGroupMembers.user_group' => $userGroup));
         }
     }
     return $c;
 }
開發者ID:ChrstnMgcn,項目名稱:revolution,代碼行數:20,代碼來源:getlist.class.php

示例3: prepareUniqObjectsQuery

 protected function prepareUniqObjectsQuery(xPDOQuery &$query)
 {
     $alias = $query->getAlias();
     $query->select(array("{$alias}.id"));
     $query->distinct();
     return $query;
 }
開發者ID:Tramp1357,項目名稱:atlasorg,代碼行數:7,代碼來源:getlist.class.php

示例4: prepareUniqObjectsQuery

 protected function prepareUniqObjectsQuery(xPDOQuery &$query)
 {
     $query->select(array("{$this->classKey}.id"));
     $query->distinct();
     return $query;
 }
開發者ID:bendasvadim,項目名稱:NewsModxBox,代碼行數:6,代碼來源:getlist.class.php


注:本文中的xPDOQuery::distinct方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。