Any way to see SQL generated by AJAX?

Hi there,

mdomba probably answered me that this is impossible in any way, but I want to ask to make myself 100% sure.

Is there any way to see SQL (or at least condition part of it i.e. CDbCriteria.condition) that is used / generated when CGridView is being updated in AJAX request as a result of either using filters, sorting or pagination?

I have extended default filter (search) form by adding two fields, declared as variables in model but not directly related to any field in table (any model property). And I’m trying to use both fields to build one compare statement (using CDbCriteria.compare). Using Firebug I can see that AJAX request is equipped with these additional fields values, but actual CGridView is not being filtered (i.e. it’s being refreshed but this particular filter is being ignored). That is why I would like to see actual SQL being used / generated in this AJAX update of CGridView.

If I’m not mistaken (correct me, if I’m wrong), if I put something like this to my view code:


echo('condition = '.$criteria->condition);

I will only be able to see condition that is being used for first time - when page is actually generated by a controller, but not condition in following AJAX request, even if they are being generated using the same view.

You should use file logging.

/Tommy

Thanks! What is the difference between CFileLogRoute and CWebLogRoute that makes first possible to log SQLs in AJAX calls and second not?

This still doesn’t solves my problem, as I still get logged SQL before binding parameters. But as mdomba told me, actual binding is made in PDO, not Yii therefore probably there isn’t any way to see complete SQLs, after binding parameters and values.

IIRC there was some modification added to ajax handling so web logging will be suspended. I may be completely wrong, though. Anyway I consider it’s best to use file logging. I won’t stand the risk losing valuable time just because the development environment/web service/ajax call swallowed some debug info.

You did know that you can see the actual parameter binding values, right.

In case you didn’t add this to the db component config




'enableParamLogging'=>true,



/Tommy

I won’t argue. I presonaly prefer CWebLogRoute as it produces (at least for me) more clear, easier to dig-through logs than file logging. But since second method is probably the only to see SQLs in AJAX request then I’ll use that one.

Yes! You’re right. mdomba told me this and I put it in my project at work, but now I’m working at some project at home and forgot about it, sorry.