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
a770f83d
Commit
a770f83d
authored
Jun 18, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DQL-to-SQL lazy conversion
parent
4346c9f8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
62 deletions
+80
-62
Query.php
lib/Doctrine/Query.php
+80
-62
No files found.
lib/Doctrine/Query.php
View file @
a770f83d
...
@@ -71,7 +71,6 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
...
@@ -71,7 +71,6 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
*/
*/
protected
$_dqlParts
=
array
(
protected
$_dqlParts
=
array
(
'select'
=>
array
(),
'select'
=>
array
(),
'distinct'
=>
false
,
'forUpdate'
=>
false
,
'forUpdate'
=>
false
,
'from'
=>
array
(),
'from'
=>
array
(),
'set'
=>
array
(),
'set'
=>
array
(),
...
@@ -99,6 +98,17 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
...
@@ -99,6 +98,17 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
{
{
return
new
Doctrine_Query
(
$conn
);
return
new
Doctrine_Query
(
$conn
);
}
}
public
function
reset
()
{
$this
->
_enumParams
=
array
();
$this
->
_pendingJoinConditions
=
array
();
$this
->
pendingSubqueries
=
array
();
$this
->
pendingFields
=
array
();
$this
->
_neededTables
=
array
();
$this
->
subqueryAliases
=
array
();
$this
->
needsSubquery
=
false
;
$this
->
isLimitSubqueryUsed
=
false
;
}
/**
/**
* setOption
* setOption
*
*
...
@@ -266,20 +276,6 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
...
@@ -266,20 +276,6 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
$this
->
_dqlParts
[
$queryPartName
]
=
array
(
$queryPart
);
$this
->
_dqlParts
[
$queryPartName
]
=
array
(
$queryPart
);
}
}
// check for cache
if
(
!
$this
->
_options
[
'resultSetCache'
])
{
$parser
=
$this
->
getParser
(
$queryPartName
);
$sql
=
$parser
->
parse
(
$queryPart
);
if
(
isset
(
$sql
))
{
if
(
$append
)
{
$this
->
addQueryPart
(
$queryPartName
,
$sql
);
}
else
{
$this
->
setQueryPart
(
$queryPartName
,
$sql
);
}
}
}
return
$this
;
return
$this
;
}
}
...
@@ -639,16 +635,36 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
...
@@ -639,16 +635,36 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
public
function
getQuery
(
$params
=
array
())
public
function
getQuery
(
$params
=
array
())
{
{
// check if parser cache is on
// check if parser cache is on
if
(
$this
->
_cache
)
{
$this
->
_aliasMap
=
array
();
$this
->
pendingAggregates
=
array
();
$this
->
aggregateMap
=
array
();
$this
->
reset
();
foreach
(
$this
->
_dqlParts
as
$queryPartName
=>
$queryParts
)
{
foreach
(
$this
->
_dqlParts
as
$queryPartName
=>
$queryParts
)
{
$this
->
parts
[
$queryPartName
]
=
array
();
if
(
is_array
(
$queryParts
)
&&
!
empty
(
$queryParts
))
{
if
(
is_array
(
$queryParts
)
&&
!
empty
(
$queryParts
))
{
foreach
(
$queryParts
as
$queryPart
)
{
foreach
(
$queryParts
as
$queryPart
)
{
$this
->
getParser
(
$queryPartName
)
->
parse
(
$queryPart
);
$parser
=
$this
->
getParser
(
$queryPartName
);
$sql
=
$parser
->
parse
(
$queryPart
);
if
(
isset
(
$sql
))
{
if
(
$queryPartName
==
'limit'
||
$queryPartName
==
'offset'
)
{
$this
->
setQueryPart
(
$queryPartName
,
$sql
);
}
else
{
$this
->
addQueryPart
(
$queryPartName
,
$sql
);
}
}
}
}
}
}
}
}
}
if
(
empty
(
$this
->
parts
[
'from'
]))
{
if
(
empty
(
$this
->
parts
[
'from'
]))
{
return
false
;
return
false
;
}
}
...
@@ -687,7 +703,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
...
@@ -687,7 +703,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
$modifyLimit
=
true
;
$modifyLimit
=
true
;
if
(
!
empty
(
$this
->
parts
[
"limit"
])
||
!
empty
(
$this
->
parts
[
"offset"
]))
{
if
(
!
empty
(
$this
->
parts
[
'limit'
])
||
!
empty
(
$this
->
parts
[
'offset'
]))
{
if
(
$needsSubQuery
)
{
if
(
$needsSubQuery
)
{
$subquery
=
$this
->
getLimitSubquery
();
$subquery
=
$this
->
getLimitSubquery
();
...
@@ -922,8 +938,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
...
@@ -922,8 +938,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
break
;
break
;
case
'update'
:
case
'update'
:
$this
->
type
=
self
::
UPDATE
;
$this
->
type
=
self
::
UPDATE
;
$k
=
'FROM'
;
$k
=
'from'
;
case
'from'
:
case
'from'
:
$this
->
parseQueryPart
(
$k
,
$part
);
$this
->
parseQueryPart
(
$k
,
$part
);
break
;
break
;
...
@@ -1155,6 +1170,8 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
...
@@ -1155,6 +1170,8 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
*/
*/
public
function
count
(
$params
=
array
())
public
function
count
(
$params
=
array
())
{
{
$this
->
getQuery
();
// initialize temporary variables
// initialize temporary variables
$where
=
$this
->
parts
[
'where'
];
$where
=
$this
->
parts
[
'where'
];
$having
=
$this
->
parts
[
'having'
];
$having
=
$this
->
parts
[
'having'
];
...
@@ -1162,6 +1179,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
...
@@ -1162,6 +1179,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
$componentAlias
=
key
(
$this
->
_aliasMap
);
$componentAlias
=
key
(
$this
->
_aliasMap
);
$table
=
$map
[
'table'
];
$table
=
$map
[
'table'
];
// build the query base
// build the query base
$q
=
'SELECT COUNT(DISTINCT '
.
$this
->
getTableAlias
(
$componentAlias
)
$q
=
'SELECT COUNT(DISTINCT '
.
$this
->
getTableAlias
(
$componentAlias
)
.
'.'
.
$table
->
getIdentifier
()
.
'.'
.
$table
->
getIdentifier
()
...
...
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