Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Link table using Orm
  • When I use a link table (one without an `id`) I get an error on this line:
    if (is_null($row[$pk_c]))

    How do I do a link table using the Orm?
  • Using protected static $_primary_key = array(); in my model appears to be working...
  • I assume you mean by "link table" the relationship or through table in a many_many relationship?

    That table does not require a primary key, as long as you don't create a model for it and use that model. For normal many_many relations its not required to create a model, it is not used by the ORM.

    If you do create a model, you have to assign a primary key. Models can't function without it.
  • That makes sense now, things were getting a bit ugly over here.

    If I don’t have a model for it, how do I write data to it?
  • HarroHarro
    Accepted Answer
    If you have to write data to it, it isn't really a link table any more. It's a table having two one-to-many relations, and requires a model, a PK, and the relations setup correctly (so no many-many anymore).
  • Aaaahhhh I’ve got it – thanks for your help Harro, working beautifully now.

Howdy, Stranger!

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

In this Discussion