如何在find或read中检索cakephp使用的查询 [英] How to retrieve the cakephp used query in find or read
问题描述
通常我们通过检查sql-dump来检查find操作。但是如果查询操作通过ajax完成是不可能的。我们如何检查任何查找操作whick cakePhp做的backgoround和任何方式打印它在pr()?
Usually we check the find operation by checking the sql-dump. But it is not possible if query operation done through ajax. How can we check any find operation whick cakePhp done in backgoround and Any way to print it in pr()?
推荐答案
找到您必须按照这些步骤进行查询
So for finding queries you have to follow these steps
1-现在转到蛋糕文件夹,找到此路径 cake\libs\model\datasources\dbo \dbo_mysql.php
1- Now go to cake folder and find this path cake\libs\model\datasources\dbo\dbo_mysql.php
2-找到函数 _execute 。这个函数负责所有查询什么cakephp从它的函数执行。
2- find the function _execute. This function is responsible for all the queries what cakephp execute from its functions.
3-调试$ sql变量像
3- debug the $sql variable like
function _execute($sql) {
echo $sql;
return mysql_query($sql, $this->connection);
}
4-在cakephp后台检索函数后丢弃代码。像
4- die the code after the cakephp background retrieval functions. like
$referral = $this->find('first', array(
'conditions' => array('Referral.id' => $id)
));
die();
5-如果这是一个ajax调用,你可以查看firebug中的查询。
5- If this is ajax call for that you can view the queries in firebug.
注意:最后一个显示的查询将是您期望的查询
这篇关于如何在find或read中检索cakephp使用的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!