hello,
I tried to find a simple way to echo the actual SQL query that I'm trying to execute. (for testing/checking purposes)
something like:
User::Model()->getQueryString()
but no luck
thanks,
–iM
hello,
I tried to find a simple way to echo the actual SQL query that I'm trying to execute. (for testing/checking purposes)
something like:
User::Model()->getQueryString()
but no luck
thanks,
–iM
maybe you set enableProfiling = true in your config (db)
then add a CProfileLogRoute as a route for the CLogRouter
this dumps all your queries at the bottom of your page
Add trace level in your log configuration inside protected/config/main.php
Or in case you want a mysql query trace (and ofc you use mysql), add:
log = /tmp/mysql.log
to your my.cnf file and restart mysql daemon.
I think both will do.
hello,
so this is not exactly what I was looking for, but it will do for now. (it's kinda weird that Yii doesn't have a simple solution for this)
so my main.php looks like this:
'components'=>array( 'log'=>array( 'class'=>'CLogRouter', 'routes'=>array( array( 'class'=>'CFileLogRoute', 'levels'=>'error, warning', ), array( 'class'=>'CWebLogRoute', 'levels' => 'trace', ), ), ),
and a little bit below …
'db'=>array( 'class'=>'CDbConnection', . . . 'enableProfiling'=>true ),
and this will display everything on the bottom part of the screen
thanks everybody for the help,
–iM
wow works perfectly!
Nice feature I didn't know.
My log is giving me SQL queries before the parameters have been replaced. Eg.
Executing SQL: INSERT INTO `Slug` (`ownerId`, `ownerTable`, `slug`) VALUES (:yp0, :yp1, :yp2)
AND
Querying SQL: SELECT COUNT(*) FROM `Slug` WHERE LOWER(slug)=?
Is there any way to see them with the parameters actually within the query? It makes it kind of hard to see what's going on.
You may configure your db connection with enableParamLogging=true.
You should turn off this in production, however, because it degrades your overall performance.