简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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