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
f1481d95
Commit
f1481d95
authored
Aug 11, 2009
by
guilhermeblanco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Added dump function for AST nodes to help debugging complex queries
parent
87979219
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
0 deletions
+52
-0
Node.php
lib/Doctrine/ORM/Query/AST/Node.php
+50
-0
Parser.php
lib/Doctrine/ORM/Query/Parser.php
+2
-0
No files found.
lib/Doctrine/ORM/Query/AST/Node.php
View file @
f1481d95
...
...
@@ -35,4 +35,54 @@ namespace Doctrine\ORM\Query\AST;
abstract
class
Node
{
abstract
public
function
dispatch
(
$sqlWalker
);
/**
* Dumps the AST Node into a string representation for information purpose only
*
* @return string
*/
public
function
__toString
()
{
return
$this
->
dump
(
$this
);
}
public
function
dump
(
$obj
)
{
static
$ident
=
0
;
$str
=
''
;
if
(
$obj
instanceof
Node
)
{
$str
.=
get_class
(
$obj
)
.
'('
.
PHP_EOL
;
$props
=
get_object_vars
(
$obj
);
foreach
(
$props
as
$name
=>
$prop
)
{
$ident
+=
4
;
$str
.=
str_repeat
(
' '
,
$ident
)
.
'"'
.
$name
.
'": '
.
$this
->
dump
(
$prop
)
.
','
.
PHP_EOL
;
$ident
-=
4
;
}
$str
.=
str_repeat
(
' '
,
$ident
)
.
')'
;
}
else
if
(
is_array
(
$obj
))
{
$ident
+=
4
;
$str
.=
'array('
;
$some
=
false
;
foreach
(
$obj
as
$k
=>
$v
)
{
$str
.=
PHP_EOL
.
str_repeat
(
' '
,
$ident
)
.
'"'
.
$k
.
'" => '
.
$this
->
dump
(
$v
)
.
','
;
$some
=
true
;
}
$ident
-=
4
;
$str
.=
(
$some
?
PHP_EOL
.
str_repeat
(
' '
,
$ident
)
:
''
)
.
')'
;
}
else
if
(
is_object
(
$obj
))
{
$str
.=
'instanceof('
.
get_class
(
$obj
)
.
')'
;
}
else
{
$str
.=
var_export
(
$obj
,
true
);
}
return
$str
;
}
}
\ No newline at end of file
lib/Doctrine/ORM/Query/Parser.php
View file @
f1481d95
...
...
@@ -257,6 +257,8 @@ class Parser
{
// Parse & build AST
$AST
=
$this
->
QueryLanguage
();
echo
PHP_EOL
.
((
string
)
$AST
)
.
PHP_EOL
;
// Check for end of string
if
(
$this
->
_lexer
->
lookahead
!==
null
)
{
...
...
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