Skip to content

Commit

Permalink
Added method distinct() in Mvc\Model\Criteria
Browse files Browse the repository at this point in the history
  • Loading branch information
KorsaR-ZN committed Jun 23, 2015
1 parent b4ed023 commit 37400a3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- Global setting orm.cast_on_hydrate allow to cast hydrated attributes to the original types in the mapped tables instead of using strings
- Values in LIMIT/OFFSET clause are now passed using bound parameters in PHQL
- Allowing late state binding in both Simple/Complex results to allow override Mvc\Model::cloneResultMap
- Added method `distinct()` in `Phalcon\Mvc\Model\Criteria` [#10536](https://github.com/phalcon/cphalcon/issues/10536)

# 2.0.3 (2015-06-10)
- Added support for Behaviors in Phalcon\Mvc\Collection
Expand Down
9 changes: 9 additions & 0 deletions phalcon/mvc/model/criteria.zep
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ class Criteria implements CriteriaInterface, InjectionAwareInterface
return this;
}

/**
* Sets SELECT DISTINCT / SELECT ALL flag
*/
public function distinct(var distinct) -> <Criteria>
{
let this->_params["distinct"] = distinct;
return this;
}

/**
* Sets the columns to be queried
*
Expand Down
9 changes: 8 additions & 1 deletion phalcon/mvc/model/query/builder.zep
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Builder implements BuilderInterface, InjectionAwareInterface
forUpdate, sharedLock, orderClause, offsetClause, joinsClause,
singleConditionArray, limit, offset, fromClause,
mergedConditions, mergedParams, mergedTypes,
singleCondition, singleParams, singleTypes, with;
singleCondition, singleParams, singleTypes, with, distinct;

if typeof params == "array" {

Expand Down Expand Up @@ -147,6 +147,13 @@ class Builder implements BuilderInterface, InjectionAwareInterface
}
}

/**
* Assign SELECT DISTINCT / SELECT ALL clause
*/
if fetch distinct, params["distinct"] {
let this->_distinct = distinct;
}

/**
* Assign FROM clause
*/
Expand Down

0 comments on commit 37400a3

Please sign in to comment.