当前位置: 首页>>代码示例>>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;未经允许,请勿转载。