Shahid Rafiq Shahid Rafiq - 6 months ago 76
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.


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.