Finding where heavy query is generated

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

It has a model where this table is referenced, and may be referenced elsewhere.

By Debugkit I'm running all the possible locales and can not find.

Would there be a better way of tracking, than searching for models or running each script and looking at debugkit?

    
asked by anonymous 15.01.2016 / 12:51

1 answer

0

It can be in several places but, by default, would be in the model with 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's ORM converts find() methods to query's.

If you search the project find('count') or find("count") you will end up finding it.

If you have a debugger, simply trace the stack trace and see the methods that were called.

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

    
05.03.2016 / 03:22