Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Fuel\Core\Fuel_Exception [ Error ]: Assigned relationships must be an array or null...
  • I'm getting the above error when trying to create record in the projects table. I've spent a good hour or so scouring the docs and forums for potential issues with the code and a fix for it but I'm unable to figure it out. I've copied the models into the below: Project Model: http://scrp.at/aqQ
    User Model: http://scrp.at/aqP Possibly something very stupid?
  • Try inserting this line at the top of the file then move the line down until error appears:
       echo __METHOD__ . ' : ' .__LINE__;  die;
    
  •   // now lets add a project and the info provided.
      $user->projects = new self();
    

    $user->projects is an array of objects, not an object. So it should be $user->projects[].
  • Harro Verton wrote on Saturday 24th of September 2011:
      // now lets add a project and the info provided.
      $user->projects = new self();
    

    $user->projects is an array of objects, not an object. So it should be $user->projects[].

    I'll test this when I get a chance tomorrow. Is this because its a 1 - many relation? Seems to be quite logical if that's the case. Thanks
  • Related objects are the result of a get() operation, which always returns an array, even if there is only one object.

Howdy, Stranger!

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

In this Discussion