简体   繁体   English

CakePHP:返回Model :: find()的SQL,而不是运行它

[英]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. 我自己的情况会比这复杂一些,但是我希望它可以说明所需的输出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM