Wednesday, April 15, 2015

Re: Cake 1.3 - Identify function that fires specific SQL statements

I found an answer to this:

Whenever you need to see the request-stack of a function, we can use

Debugger::trace();

to display the hierarchical list of requests for any function. 




Am Donnerstag, 19. März 2015 13:03:51 UTC+1 schrieb DigitalDude:
Hey,


I have a specific problem with one of my apps which is the result of some queries build by cake and then "stall" within the database. I know WHY this is happening and I can fix these queries by shrinking them with the fields operator (and other tricks), but since the app is kind of complex I need help with the following task:

Is it possible to identify which action fired a specific query?

In the core, cake/libs/model/datasources/dbo_source.php -> line 248 function "execute" will have the variable $sql where the query from query is placed and then fired. So far, so good. It would be just perfect if I could find out what cake-function passed this query, because I can check if the query is going to stall the database (simple strpos() check, then log the query into a log-file so I have a list of them).

Another way could be to add a code-snippet within a central place (app controller?) to get the query log of EVERY action that is called. 

Does anyone have an idea if that would be possible?

A new version is already developed without any stalling queries, but this cannot be deployed for 2 more weeks as the customer is still testing the development build....



P.S: FYI the queries are i18n related on models that have up to 35 i18n fields,  and that will break the database because of the joins cake is building when queries are not specific enough (no fields-option set for queries).

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: