Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.0.x] Added method distinct() in Mvc\Model\Criteria #10538

Merged
merged 1 commit into from
Jun 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be a boolean?

{
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