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 from X where Y

I've been trying to find out how to delete data within a model using something like :

$this->delete( array( 'conditions' => 'email = :email: and entity_type = :entity_type:', 'bind' => array( 'email' => $email, 'entity_type' => $entityType ) ) );

maybe with a return type of int which contains the number of records deleted.

It is madness to do a select, then iterate over the result set and delete records individually, as it says in the documentation.

Can someone put me out of my misery and tell me what I am missing here!!!

Thanks. Mark



98.9k

Phalcon ORM does not implement a Table Data Gateway pattern but it implements a different pattern, so it can't perform an operation directly over table without triggering related events in the model per each row.