Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Tomáš Trávníček
doctrine-dbal
Commits
a39199f2
Commit
a39199f2
authored
Jan 27, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DQL ORDER BY now supports ordering by an aggregate value
parent
84a7fb79
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
6 deletions
+35
-6
Hydrate.php
lib/Doctrine/Hydrate.php
+4
-1
Query.php
lib/Doctrine/Query.php
+19
-2
Orderby.php
lib/Doctrine/Query/Orderby.php
+8
-3
JoinConditionTestCase.php
tests/Query/JoinConditionTestCase.php
+4
-0
No files found.
lib/Doctrine/Hydrate.php
View file @
a39199f2
...
@@ -85,7 +85,10 @@ abstract class Doctrine_Hydrate extends Doctrine_Access
...
@@ -85,7 +85,10 @@ abstract class Doctrine_Hydrate extends Doctrine_Access
protected
$tableIndexes
=
array
();
protected
$tableIndexes
=
array
();
protected
$pendingAggregates
=
array
();
protected
$pendingAggregates
=
array
();
/**
* @var array $aggregateMap an array containing all aggregate aliases, keys as dql aliases
* and values as sql aliases
*/
protected
$aggregateMap
=
array
();
protected
$aggregateMap
=
array
();
/**
/**
* @var Doctrine_Hydrate_Alias $aliasHandler
* @var Doctrine_Hydrate_Alias $aliasHandler
...
...
lib/Doctrine/Query.php
View file @
a39199f2
...
@@ -76,6 +76,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
...
@@ -76,6 +76,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
* @var array $pendingFields
* @var array $pendingFields
*/
*/
private
$pendingFields
=
array
();
private
$pendingFields
=
array
();
/**
/**
* @var integer $type the query type
* @var integer $type the query type
*
*
...
@@ -115,6 +116,20 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
...
@@ -115,6 +116,20 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
$this
->
isSubquery
=
(
bool
)
$bool
;
$this
->
isSubquery
=
(
bool
)
$bool
;
return
$this
;
return
$this
;
}
}
/**
* getAggregateAlias
*
* @return string
*/
public
function
getAggregateAlias
(
$dqlAlias
)
{
if
(
isset
(
$this
->
aggregateMap
[
$dqlAlias
]))
{
return
$this
->
aggregateMap
[
$dqlAlias
];
}
return
null
;
}
public
function
getTableStack
()
public
function
getTableStack
()
{
{
return
$this
->
tableStack
;
return
$this
->
tableStack
;
...
@@ -257,9 +272,11 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
...
@@ -257,9 +272,11 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
}
}
}
}
$this
->
parts
[
'select'
][]
=
$name
.
'('
.
$distinct
.
implode
(
', '
,
$arglist
)
.
') AS '
.
$tableAlias
.
'__'
.
count
(
$this
->
aggregateMap
);
$sqlAlias
=
$tableAlias
.
'__'
.
count
(
$this
->
aggregateMap
);
$this
->
parts
[
'select'
][]
=
$name
.
'('
.
$distinct
.
implode
(
', '
,
$arglist
)
.
') AS '
.
$sqlAlias
;
$this
->
aggregateMap
[
]
=
$table
;
$this
->
aggregateMap
[
$alias
]
=
$sqlAlias
;
$this
->
neededTables
[]
=
$tableAlias
;
$this
->
neededTables
[]
=
$tableAlias
;
}
}
}
}
...
...
lib/Doctrine/Query/Orderby.php
View file @
a39199f2
...
@@ -60,10 +60,15 @@ class Doctrine_Query_Orderby extends Doctrine_Query_Part
...
@@ -60,10 +60,15 @@ class Doctrine_Query_Orderby extends Doctrine_Query_Part
$r
=
$alias
.
'.'
.
$field
;
$r
=
$alias
.
'.'
.
$field
;
}
else
{
$field
=
$this
->
query
->
getAggregateAlias
(
$e
[
0
]);
$r
=
$field
;
}
if
(
isset
(
$e
[
1
]))
{
if
(
isset
(
$e
[
1
]))
{
$r
.=
' '
.
$e
[
1
];
$r
.=
' '
.
$e
[
1
];
}
}
}
$ret
[]
=
$r
;
$ret
[]
=
$r
;
}
}
...
...
tests/Query/JoinConditionTestCase.php
View file @
a39199f2
...
@@ -32,6 +32,10 @@
...
@@ -32,6 +32,10 @@
*/
*/
class
Doctrine_Query_JoinCondition_TestCase
extends
Doctrine_UnitTestCase
class
Doctrine_Query_JoinCondition_TestCase
extends
Doctrine_UnitTestCase
{
{
public
function
prepareData
()
{
}
public
function
prepareTables
()
{
}
public
function
testJoinConditionsAreSupportedForOneToManyLeftJoins
()
public
function
testJoinConditionsAreSupportedForOneToManyLeftJoins
()
{
{
$q
=
new
Doctrine_Query
();
$q
=
new
Doctrine_Query
();
...
...
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