we using symfony 1.0. We have an module work with Propel objects. The sql-querys are visible in the symfony-debugbar under the "DB" menu.
My problem is that we also use custom sql-querys via propel::getRS("select ...") This querys are not visible in the debug bar.
Does anyone have an idea how to do that?
Recommended way
The standard logger in symfony would be the recommended method:
from inside an action:
$this->logMessage('executed SQL: '.$sql);
from inside the model (or anywhere else):
sfContext::getInstance()->getLogger()->info('executed SQL: '.$sql);
These methods would insert your SQL queries into the 'logs & msgs' tab in the debug toolbar in the correct position in the execution chain.
However, if you just want to see the queries at the top of the 'logs & msgs' tab and don't need them to be stored in the permanent log, you can use $this->debugMessage($sql);
instead, which would also mean you could see the queries together, and not search for them through the log execution chain.
A potentially preferable way
I suspect that you may want these SQL queries to appear on the 'DB' tab instead. This isn't directly supported by symfony, but you could 'hack' this solution instead:
from inside an action:
$this->logMessage(sprintf("{sfCreole} executeQuery(): [x.xx ms] %s", $sql));
from inside the model:
sfContext::getInstance()->getLogger()->info(sprintf("{sfCreole} executeQuery(): [x.xx ms] %s", $sql));
This mimics the behaviour of the debug option in symfony for logging SQL queries, and will therefore push your custom SQL query into the 'DB' tab in the debug toolbar. I leave the timing [x.xx ms] option up to you to implement if you wish it :)