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

Delete many records from table

Can I produce query like «DELETE FROM table WHERE condition» by \Phalcon\Model class? Similar example presented in documentation (https://docs.phalcon.io/en/latest/reference//models.html#deleting-records), but SELECT with condition and deleting each manually is not a very good idea for me.



98.9k

No, Phalcon\Mvc\Model does not implement a table data gateway pattern, you can use the Db component to send a direct delete to the database:

$this->db->delete("robots", "id > 100")