Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
cd17761f
Commit
cd17761f
authored
Feb 06, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix distinct problems in paginator.
parent
e89082e3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
13 deletions
+10
-13
query.php
laravel/database/query.php
+7
-12
grammar.php
laravel/database/query/grammars/grammar.php
+3
-1
No files found.
laravel/database/query.php
View file @
cd17761f
...
...
@@ -626,12 +626,12 @@ class Query {
* Get an aggregate value.
*
* @param string $aggregator
* @param
string $column
* @param
array $columns
* @return mixed
*/
public
function
aggregate
(
$aggregator
,
$column
)
public
function
aggregate
(
$aggregator
,
$column
s
)
{
$this
->
aggregate
=
compact
(
'aggregator'
,
'column'
);
$this
->
aggregate
=
compact
(
'aggregator'
,
'column
s
'
);
$sql
=
$this
->
grammar
->
select
(
$this
);
...
...
@@ -660,7 +660,7 @@ class Query {
// we have the count.
list
(
$orderings
,
$this
->
orderings
)
=
array
(
$this
->
orderings
,
null
);
$page
=
Paginator
::
page
(
$total
=
$this
->
count
(),
$per_page
);
$page
=
Paginator
::
page
(
$total
=
$this
->
count
(
$columns
),
$per_page
);
$this
->
orderings
=
$orderings
;
...
...
@@ -818,14 +818,9 @@ class Query {
if
(
in_array
(
$method
,
array
(
'count'
,
'min'
,
'max'
,
'avg'
,
'sum'
)))
{
if
(
$method
==
'count'
)
{
return
$this
->
aggregate
(
strtoupper
(
$method
),
'*'
);
}
else
{
return
$this
->
aggregate
(
strtoupper
(
$method
),
$parameters
[
0
]);
}
if
(
count
(
$parameters
)
==
0
)
$parameters
[
0
]
=
'*'
;
return
$this
->
aggregate
(
strtoupper
(
$method
),
(
array
)
$parameters
[
0
]);
}
throw
new
\Exception
(
"Method [
$method
] is not defined on the Query class."
);
...
...
laravel/database/query/grammars/grammar.php
View file @
cd17761f
...
...
@@ -93,7 +93,9 @@ class Grammar extends \Laravel\Database\Grammar {
*/
protected
function
aggregate
(
Query
$query
)
{
$column
=
$this
->
wrap
(
$query
->
aggregate
[
'column'
]);
$column
=
$this
->
columnize
(
$query
->
aggregate
[
'columns'
]);
if
(
$query
->
distinct
and
$column
!==
'*'
)
$column
=
'DISTINCT '
.
$column
;
return
'SELECT '
.
$query
->
aggregate
[
'aggregator'
]
.
'('
.
$column
.
')'
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment