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

Foreign key action set null

Hi, How i can set NULL when my entry has been deleted? Relation class have ACTION_RESTRICT and ACTION_CASCADE, but there is no ACTION_SETNULL. No such examples in documentation. I have not found anything like it in the documentation.

Which DB are you using?



509

I'm using MySQL 5.5

Then I recommend to use native SQL InnoDB storage engine and define foreign keys correctly there. Do not use Phalcon relation restrictions, its much better to use native MySQL functionality, its faster and there is no need to replicate the same functionality by Phalcon, which will handle it worse.



509

Very sad to hear that. If i'd use native SQL foreign keys, i still need to describing them in the model to have access like this:

$model->relatedModels