We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to show last sql string from criteria

I want to get real last sql generate from criteria before connect and execute with mysql, but i didn't found a function to do it. My code seem:

$query = Data::query();
$query->orderBy('c_id DESC');
$list_data = $query->execute();

Tks you for your answer. Infact, i wrote a function to get sql statement from Phalcon\Mvc\Model\Resultset\Simple ( with low level mean have ex: :type: instead of type value - if i understand correctly ) , but of course it only working when i have a correct query. I will get error when the query is incorrect but i want to get last sql statement to know my mistake. The PROFILES way got a same problem. The last sql which exactly put to database will alway help me found my mistake, and i think i must use LOG way to do it although it isn't good for quick debug.