Find where heavy query is generated

Asked

Viewed 50 times

3

Good morning I need to find where in Cakephp 2.5.2 this query is performed:

SELECT COUNT(*) AS count FROM umatabela WHERE status = 1

Has a model where this table is referenced, and may be referenced in other places.

By Debugkit I am running all possible locations and can not find.

There would be a better way to track, than to look for models or run each script and look at debugkit?

  • Are you paging? Paging components perform select with COUNT to pick the total amount.

  • I imagine having no option the worst that is on top of a view from there gets slower . I imagine just force more search criteria . Just do not find in debugkit maybe for being an internal query that cake does not appear in debugkit then

  • 1

    Partner... are you sure this is what the query looks like??? if you have, you can use your IDE’s own search (if you use one)... just Ctrl + H type this query into the field and ask to search throughout your project.

1 answer

0

It can be in several places but, by default, would be in the model with a name similar to the table, usually in the singular.

A common call that could generate this sql would be:

$this->find("count").

Or

$UmaTabela->find('count').

Cake ORM converts methods find() in query’s.

Search in the project find('count') or find("count") will eventually find.

If you have Debugger, just track the stack trace and see the methods that have been called.

Where 1=1 is added for security when there are no search conditions, sql Injection prevention.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.