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

ORM and phql

How can I use phalcon to delete from two tables in my db , sharing in comong a field with the same name. I have in my db a table pruduct and categories, both of them have the field cat_id like to delete all products belonging to a category when I delete the category.

edited Sep '16

That's what referential integrity is for. If you define a product's table foreign key (product->category) as ON DELETE CASCADE, that's it, when you delete a category it will delete sequentially all products belonging to that category. Now that's 'by the book', to actually use relations in a RDBMS. If you're looking for other way i.e. with an ORM from application, that's also possible, but IMHO relations should always come first.