Is there a way to output sql generated by selecting propel in symfony?

I want to output a query generated by selecting symfony propel for testing. Is there any way to do this? I know that I can use the sf_debug panel, but sometimes I need to see the instruction in a situation where the sf_debug panel is not loaded yet or will not load at all.

+3
source share
4 answers

Timmow is right that there is a method Criteria::toString(), but it is not a magic method _toString()that is automatically called when an object is referenced as a string.

If you want to see SQL, you must explicitly call Criteria::toString().

$c = new Criteria();
// HERE: add criteria
// what it do?
echo $c->toString(); // oh, that what it does
+4
source

Propel Criteria toString, echo/var_dump/log ,

0

It may also be useful to take a look at Day 6 of the Jobeet tutorial, Debugging Propel Generated SQL . If you are in a debugging environment, raw requests are output to the log files. 100% sure that I am using the Doctrine.

0
source

You will receive the generated SQL statement after you build the criteria:

    $params= array();
    $resulting_sql_statement = BasePeer::createSelectSql($criteria,$params);
0
source

Source: https://habr.com/ru/post/1721706/


All Articles