How to echo last query string in Phalcon?

后端 未结 2 1721
渐次进展
渐次进展 2020-12-20 07:17

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->l         


        
2条回答
  •  天涯浪人
    2020-12-20 08:07

    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($result);
    

    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.

提交回复
热议问题