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
3500a6fb
Commit
3500a6fb
authored
Dec 10, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added parseFunctionExpression
parent
e5d43b2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
22 deletions
+32
-22
Query.php
lib/Doctrine/Query.php
+32
-22
No files found.
lib/Doctrine/Query.php
View file @
3500a6fb
...
...
@@ -706,32 +706,14 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria
$str
=
''
;
foreach
(
$terms
as
$term
)
{
$pos
=
strpos
(
$term
[
0
],
'('
);
if
(
$pos
!==
false
)
{
$name
=
substr
(
$term
[
0
],
0
,
$pos
);
if
(
$name
!==
''
)
{
$argStr
=
substr
(
$term
[
0
],
(
$pos
+
1
),
-
1
);
$args
=
array
();
// parse args
foreach
(
$this
->
_tokenizer
->
sqlExplode
(
$argStr
,
','
)
as
$expr
)
{
$args
[]
=
$this
->
parseClause
(
$expr
);
}
// convert DQL function to its RDBMS specific equivalent
try
{
$expr
=
call_user_func_array
(
array
(
$this
->
_conn
->
expression
,
$name
),
$args
);
}
catch
(
Doctrine_Expression_Exception
$e
)
{
throw
new
Doctrine_Query_Exception
(
'Unknown function '
.
$expr
.
'.'
);
}
$term
[
0
]
=
$expr
;
}
else
{
$term
[
0
]
=
$this
->
parseSubquery
(
$term
[
0
]);
}
$term
[
0
]
=
$this
->
parseFunctionExpression
(
$term
[
0
]);
}
else
{
if
(
substr
(
$term
[
0
],
0
,
1
)
!==
"'"
&&
substr
(
$term
[
0
],
-
1
)
!==
"'"
)
{
if
(
strpos
(
$term
[
0
],
'.'
)
!==
false
)
{
if
(
!
is_numeric
(
$term
[
0
]))
{
$e
=
explode
(
'.'
,
$term
[
0
]);
...
...
@@ -838,6 +820,34 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria
}
return
$str
;
}
public
function
parseFunctionExpression
(
$expr
)
{
$pos
=
strpos
(
$expr
,
'('
);
$name
=
substr
(
$expr
,
0
,
$pos
);
if
(
$name
===
''
)
{
return
$this
->
parseSubquery
(
$expr
);
}
$argStr
=
substr
(
$expr
,
(
$pos
+
1
),
-
1
);
$args
=
array
();
// parse args
foreach
(
$this
->
_tokenizer
->
sqlExplode
(
$argStr
,
','
)
as
$arg
)
{
$args
[]
=
$this
->
parseClause
(
$arg
);
}
// convert DQL function to its RDBMS specific equivalent
try
{
$expr
=
call_user_func_array
(
array
(
$this
->
_conn
->
expression
,
$name
),
$args
);
}
catch
(
Doctrine_Expression_Exception
$e
)
{
throw
new
Doctrine_Query_Exception
(
'Unknown function '
.
$name
.
'.'
);
}
return
$expr
;
}
public
function
parseSubquery
(
$subquery
)
{
$trimmed
=
trim
(
$this
->
_tokenizer
->
bracketTrim
(
$subquery
));
...
...
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