Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Do I have to manually brake all one-to-one relationships?
  • I have an article model that has one gallery relationship. Meaning that galleries table holds "article_id" field according to ORM specs: Has its primary key saved in one other row of another table (which belongs to this), has 1 related object. If I call delete on Model_Article it will not break relationship, the linked gallery record will still hold the deleted article in field article_id. Do I have to explicitly break relationship, before deleting and article, like this?
    $article = Model_Article::find($id);
    $article->gallery = null;
    $article->save();
    $article->delete();
    

    What is the reason delete doesn't handle this by itself?
  • That should work fine, I don't know why it doesn't anymore - I tried to replicate it and got the same result. Could you create a bug report on Github?
  • Jelmer Schreuder wrote on Sunday 12th of February 2012:
    That should work fine, I don't know why it doesn't anymore - I tried to replicate it and got the same result. Could you create a bug report on Github?

    Hi Jelmer... I have opened the issue here: https://github.com/fuel/orm/issues/135! I was breaking my head over this yesterday. Haven't noticed you made a reply to this until now. Please let me know if you put up the fix for this.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion