BUGFIX: Fixed bug in SQLQuery::unlimitedRowCount() when used with grouped queries, that should fix a lot of pagination situations.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@68940 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-12-15 03:12:36 +00:00
parent f0e661a253
commit 5a5bdef2ba

View File

@ -445,7 +445,16 @@ class SQLQuery extends Object {
*
* TODO Respect HAVING and GROUPBY, which can affect the result-count
*/
function unlimitedRowCount( $column = "*" ) {
function unlimitedRowCount( $column = null) {
// Choose a default column
if($column == null) {
if($this->groupby) {
$column = 'DISTINCT ' . implode(", ", $this->groupby);
} else {
$column = '*';
}
}
$clone = clone $this;
$clone->select = array("count($column)");
$clone->limit = null;