Shahid Rafiq Shahid Rafiq - 1 year ago 268
SQL Question

How to echo last query string in Phalcon?

I have worked a lot on codeigniter. In codeigniter , if there is need to get query string that is executed last, we can get it using:

echo $this->db->last_query();

But currently I am working on phalcon and I am just at beginner level in this framework. I am curious if there is a way to echo last query string in phalcon.

Thank you.

Answer Source

If you are running queries directly on your model instance and you are lazy, you can also do it like this:

$result = $this->_userEntriesE‌​ntries->find(array("c‌​onditions" => "FeaturedPost = 1 and FeaturedPostStatus = 1", "order" => "ID DESC", "limit" => 4))


var_dump the result object of your query. Within the PDO dump you will notice a key named _pdoStatement. This is your generated SQL query.

This is not the recommended way, just a dirty trick.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download