Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Last SQL Query

Hi guys, i'd searched on forum but there is only old answers, and unreliable ones.

How can I get the last SQL executed on Phalcon 4?

Thanks



5.6k
Accepted
answer

its still the same with phalcon 4

check the API documentaion

check this answer here also


$phql = 'UPDATE `news` SET `category_id` = 5 WHERE `id` = :id';

$this->db->execute($phql, ['id' => 1]);

print_r($this->db->getSQLStatement());

print_r($this->db->getSqlVariables());

News::findFirst();

print_r($this->db->getSQLStatement());

print_r($this->db->getSqlVariables());

and i would recommend checking the class Phalcon\Db\Profiler