本文整理汇总了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;
}
示例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;
}
示例3: prepareUniqObjectsQuery
protected function prepareUniqObjectsQuery(xPDOQuery &$query)
{
$alias = $query->getAlias();
$query->select(array("{$alias}.id"));
$query->distinct();
return $query;
}
示例4: prepareUniqObjectsQuery
protected function prepareUniqObjectsQuery(xPDOQuery &$query)
{
$query->select(array("{$this->classKey}.id"));
$query->distinct();
return $query;
}