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
b1a78756
Commit
b1a78756
authored
May 24, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
bf263fe1
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
35 additions
and
80 deletions
+35
-80
Query.php
lib/Doctrine/Query.php
+22
-19
Abstract.php
lib/Doctrine/Query/Abstract.php
+1
-1
Condition.php
lib/Doctrine/Query/Condition.php
+4
-4
From.php
lib/Doctrine/Query/From.php
+1
-1
Groupby.php
lib/Doctrine/Query/Groupby.php
+1
-6
Having.php
lib/Doctrine/Query/Having.php
+0
-9
Limit.php
lib/Doctrine/Query/Limit.php
+1
-3
Offset.php
lib/Doctrine/Query/Offset.php
+1
-3
Orderby.php
lib/Doctrine/Query/Orderby.php
+1
-7
Part.php
lib/Doctrine/Query/Part.php
+0
-10
Select.php
lib/Doctrine/Query/Select.php
+1
-4
Set.php
lib/Doctrine/Query/Set.php
+2
-4
Where.php
lib/Doctrine/Query/Where.php
+0
-9
No files found.
lib/Doctrine/Query.php
View file @
b1a78756
...
...
@@ -241,13 +241,27 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
*/
public
function
parseQueryPart
(
$queryPartName
,
$queryPart
,
$append
=
false
)
{
if
(
$queryPart
===
''
||
$queryPart
===
null
)
{
throw
new
Doctrine_Query_Exception
(
'Empty '
.
$queryPartName
.
' part given.'
);
}
if
(
$append
)
{
$this
->
_dqlParts
[
$queryPartName
][]
=
$queryPart
;
}
else
{
$this
->
_dqlParts
[
$queryPartName
]
=
array
(
$queryPart
);
}
if
(
!
$this
->
_options
[
'resultSetCache'
]
&&
!
$this
->
_options
[
'parserCache'
])
{
$this
->
getParser
(
$queryPartName
)
->
parse
(
$queryPart
);
$parser
=
$this
->
getParser
(
$queryPartName
);
$sql
=
$parser
->
parse
(
$queryPart
);
if
(
isset
(
$sql
))
{
if
(
$append
)
{
$this
->
addQueryPart
(
$queryPartName
,
$sql
);
}
else
{
$this
->
setQueryPart
(
$queryPartName
,
$sql
);
}
}
}
return
$this
;
...
...
@@ -562,7 +576,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
if
(
!
empty
(
$e2
))
{
$parser
=
new
Doctrine_Query_JoinCondition
(
$this
);
$part
.=
' AND '
.
$parser
->
_
parse
(
implode
(
' AND '
,
$e2
));
$part
.=
' AND '
.
$parser
->
parse
(
implode
(
' AND '
,
$e2
));
}
$q
.=
' '
.
$part
;
...
...
@@ -856,7 +870,8 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
foreach
(
$parts
as
$k
=>
$part
)
{
$part
=
implode
(
' '
,
$part
);
switch
(
strtolower
(
$k
))
{
$k
=
strtolower
(
$k
);
switch
(
$k
)
{
case
'create'
:
$this
->
type
=
self
::
CREATE
;
break
;
...
...
@@ -868,38 +883,26 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
break
;
case
'select'
:
$this
->
type
=
self
::
SELECT
;
$this
->
parse
Select
(
$part
);
$this
->
parse
QueryPart
(
$k
,
$part
);
break
;
case
'update'
:
$this
->
type
=
self
::
UPDATE
;
$k
=
'FROM'
;
case
'from'
:
$class
=
'Doctrine_Query_'
.
ucwords
(
strtolower
(
$k
));
$parser
=
new
$class
(
$this
);
$parser
->
parse
(
$part
);
$this
->
parseQueryPart
(
$k
,
$part
);
break
;
case
'set'
:
$class
=
'Doctrine_Query_'
.
ucwords
(
strtolower
(
$k
));
$parser
=
new
$class
(
$this
);
$parser
->
parse
(
$part
);
$this
->
parseQueryPart
(
$k
,
$part
,
true
);
break
;
case
'group'
:
case
'order'
:
$k
.=
'by'
;
case
'where'
:
case
'having'
:
$class
=
'Doctrine_Query_'
.
ucwords
(
strtolower
(
$k
));
$parser
=
new
$class
(
$this
);
$name
=
strtolower
(
$k
);
$parser
->
parse
(
$part
);
break
;
case
'limit'
:
$this
->
parts
[
'limit'
]
=
trim
(
$part
);
break
;
case
'offset'
:
$this
->
par
ts
[
'offset'
]
=
trim
(
$part
);
$this
->
par
seQueryPart
(
$k
,
$part
);
break
;
}
}
...
...
lib/Doctrine/Query/Abstract.php
View file @
b1a78756
...
...
@@ -171,7 +171,7 @@ abstract class Doctrine_Query_Abstract extends Doctrine_Hydrate
*/
public
function
set
(
$key
,
$value
)
{
return
$this
->
parseQueryPart
(
'set'
,
$key
.
' = '
.
$value
);
return
$this
->
parseQueryPart
(
'set'
,
$key
.
' = '
.
$value
,
true
);
}
/**
* from
...
...
lib/Doctrine/Query/Condition.php
View file @
b1a78756
...
...
@@ -39,7 +39,7 @@ abstract class Doctrine_Query_Condition extends Doctrine_Query_Part
* @param string $str
* @return string
*/
public
function
_
parse
(
$str
)
public
function
parse
(
$str
)
{
$tmp
=
trim
(
$str
);
...
...
@@ -49,7 +49,7 @@ abstract class Doctrine_Query_Condition extends Doctrine_Query_Part
$ret
=
array
();
foreach
(
$parts
as
$part
)
{
$part
=
Doctrine_Tokenizer
::
bracketTrim
(
$part
,
'('
,
')'
);
$ret
[]
=
$this
->
_
parse
(
$part
);
$ret
[]
=
$this
->
parse
(
$part
);
}
$r
=
implode
(
' AND '
,
$ret
);
}
else
{
...
...
@@ -59,12 +59,12 @@ abstract class Doctrine_Query_Condition extends Doctrine_Query_Part
$ret
=
array
();
foreach
(
$parts
as
$part
)
{
$part
=
Doctrine_Tokenizer
::
bracketTrim
(
$part
,
'('
,
')'
);
$ret
[]
=
$this
->
_
parse
(
$part
);
$ret
[]
=
$this
->
parse
(
$part
);
}
$r
=
implode
(
' OR '
,
$ret
);
}
else
{
if
(
substr
(
$parts
[
0
],
0
,
1
)
==
'('
&&
substr
(
$parts
[
0
],
-
1
)
==
')'
)
{
return
$this
->
_
parse
(
substr
(
$parts
[
0
],
1
,
-
1
));
return
$this
->
parse
(
substr
(
$parts
[
0
],
1
,
-
1
));
}
else
{
return
$this
->
load
(
$parts
[
0
]);
}
...
...
lib/Doctrine/Query/From.php
View file @
b1a78756
...
...
@@ -84,7 +84,7 @@ class Doctrine_Query_From extends Doctrine_Query_Part
$operator
=
(
$last
==
'INNER'
)
?
':'
:
'.'
;
}
return
$this
->
query
;
return
null
;
}
}
lib/Doctrine/Query/Groupby.php
View file @
b1a78756
...
...
@@ -51,11 +51,6 @@ class Doctrine_Query_Groupby extends Doctrine_Query_Part
$r
[]
=
$this
->
query
->
getTableAlias
(
$ref
)
.
'.'
.
$field
;
}
if
(
$append
)
{
$this
->
query
->
addQueryPart
(
'groupby'
,
implode
(
', '
,
$r
));
}
else
{
$this
->
query
->
setQueryPart
(
'groupby'
,
implode
(
', '
,
$r
));
}
return
$this
->
query
;
return
implode
(
', '
,
$r
);
}
}
lib/Doctrine/Query/Having.php
View file @
b1a78756
...
...
@@ -32,15 +32,6 @@ Doctrine::autoload('Doctrine_Query_Condition');
*/
class
Doctrine_Query_Having
extends
Doctrine_Query_Condition
{
public
function
parse
(
$str
,
$append
=
false
)
{
if
(
$append
)
{
$this
->
query
->
addQueryPart
(
'having'
,
$this
->
_parse
(
$str
));
}
else
{
$this
->
query
->
setQueryPart
(
'having'
,
$this
->
_parse
(
$str
));
}
return
$this
->
query
;
}
/**
* DQL Aggregate Function parser
*
...
...
lib/Doctrine/Query/Limit.php
View file @
b1a78756
...
...
@@ -34,8 +34,6 @@ class Doctrine_Query_Limit extends Doctrine_Query_Part
{
public
function
parse
(
$limit
)
{
$this
->
query
->
setQueryPart
(
'limit'
,
(
int
)
$limit
);
return
$this
->
query
;
return
(
int
)
$limit
;
}
}
lib/Doctrine/Query/Offset.php
View file @
b1a78756
...
...
@@ -34,8 +34,6 @@ class Doctrine_Query_Offset extends Doctrine_Query_Part
{
public
function
parse
(
$offset
)
{
$this
->
query
->
setQueryPart
(
'offset'
,
(
int
)
$offset
);
return
$this
->
query
;
return
(
int
)
$offset
;
}
}
lib/Doctrine/Query/Orderby.php
View file @
b1a78756
...
...
@@ -69,12 +69,6 @@ class Doctrine_Query_Orderby extends Doctrine_Query_Part
}
$ret
[]
=
$r
;
}
if
(
$append
)
{
$this
->
query
->
addQueryPart
(
'orderby'
,
implode
(
', '
,
$ret
));
}
else
{
$this
->
query
->
setQueryPart
(
'orderby'
,
implode
(
', '
,
$ret
));
}
return
$this
->
query
;
return
implode
(
', '
,
$ret
);
}
}
lib/Doctrine/Query/Part.php
View file @
b1a78756
...
...
@@ -50,14 +50,4 @@ abstract class Doctrine_Query_Part
{
return
$this
->
query
;
}
/**
public function parse($dql, $append = false)
{
$e = explode(' ', __CLASS__);
$name = end($e);
$this->query->addDqlPart($name, $dql);
$this->_parse($dql);
}
*/
}
lib/Doctrine/Query/Select.php
View file @
b1a78756
...
...
@@ -34,11 +34,8 @@ class Doctrine_Query_Select extends Doctrine_Query_Part
{
public
function
parse
(
$dql
)
{
if
(
$dql
===
''
||
$dql
===
null
)
{
throw
new
Doctrine_Query_Exception
(
'Empty select part given.'
);
}
$this
->
query
->
parseSelect
(
$dql
);
return
$this
->
query
;
return
null
;
}
}
lib/Doctrine/Query/Set.php
View file @
b1a78756
...
...
@@ -45,15 +45,13 @@ class Doctrine_Query_Set extends Doctrine_Query_Part
$reference
=
implode
(
'.'
,
$e
);
$alias
=
$this
->
query
->
getTableAlias
(
$reference
);
$alias
=
$this
->
query
->
getTableAlias
(
$reference
);
$map
=
$this
->
query
->
getAliasDeclaration
(
$reference
);
$result
[]
=
$map
[
'table'
]
->
getColumnName
(
$field
)
.
' = '
.
$set
[
1
];
}
$this
->
query
->
addQueryPart
(
'set'
,
implode
(
', '
,
$result
));
return
$this
->
query
;
return
implode
(
', '
,
$result
)
;
}
}
lib/Doctrine/Query/Where.php
View file @
b1a78756
...
...
@@ -32,15 +32,6 @@ Doctrine::autoload('Doctrine_Query_Condition');
*/
class
Doctrine_Query_Where
extends
Doctrine_Query_Condition
{
public
function
parse
(
$str
,
$append
=
false
)
{
if
(
$append
)
{
$this
->
query
->
addQueryPart
(
'where'
,
$this
->
_parse
(
$str
));
}
else
{
$this
->
query
->
setQueryPart
(
'where'
,
$this
->
_parse
(
$str
));
}
return
$this
->
query
;
}
/**
* load
* returns the parsed query part
...
...
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