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

[SOLVED]How to update database by a raw sql?

Dear experts,

I want to execute raw simple query like:

UPDATE comments SET sort_order = :order: WHERE id = :id:

How to do that in Phalcon?

PS: I try to avoid PHQL because I read that it will do select first then update (2 round database trips)

Thanks

Jim



404

$this->db->query("UPDATE comments SET sort_order = ? WHERE id = ? ", array($sort_order, $comment_id));

Tested it and it doesn't select table schema before update.

@Andrey It works. Thanks.