[英]CakePHP: Return the SQL for Model::find() rather than running it
Is there a way to get the SQL which would be run for a particular find()
query, rather than actually running it? 有没有一种方法可以获取要针对特定
find()
查询运行的SQL,而不是实际运行的SQL?
For example: 例如:
echo $this->Users->find_sql('all');
// "SELECT User.id, User.username FROM users User WHERE 1=1"
My own situation would be a little more complicated than this, but I hope it illustrates the desired output. 我自己的情况会比这复杂一些,但是我希望它可以说明所需的输出。
found this article a while back 前阵子发现了这篇文章
http://bakery.cakephp.org/articles/view/get-the-find-query-sql-rather-than-query-result http://bakery.cakephp.org/articles/view/get-the-find-query-sql-rather-than-query-result
hope it helps 希望能帮助到你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.