I want to output the query generated by a symfony propel select for testing purposes. Is there any way to do this? I know I can use the sf_debug bar, but sometimes I need to see the statement in a situation where the sf_debug bar hasn't loaded yet, or isn't going to load at all.
views:
219answers:
3
A:
It also might be helpful to take a look at Day 6 of the Jobeet Tutorial, Debugging Propel generated SQL. If you're in the debug environment, the raw queries are output to the log files. Not 100% sure as I use Doctrine.
nselikoff
2009-11-02 23:22:21
+1
A:
Timmow is right that there is a Criteria::toString()
method, but it's not the magic _toString()
method that's automatically called when the object is referenced as a string.
If you want to see the SQL you have to explicitly call Criteria::toString()
.
$c = new Criteria();
// HERE: add criteria
// what's it do?
echo $c->toString(); // oh, that's what it does
dibson
2009-11-03 23:38:24
Interesting - it "sorta" works - I get this output for the page I happen to be working on:Criteria: SQL (may not be complete): SELECT FROM ORDER BY ugc_question.LAST_RESPONSE_AT DESC Params:
kewpiedoll99
2009-11-04 16:03:50
also, the above code snippet should say echo $c->toString(); // oh...(not $c->getString(); )
kewpiedoll99
2009-11-24 22:49:03
just updated it, thanks for the extra eye
dibson
2009-12-15 17:23:51