Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
key_from of has_one must be primary key?
  • key_from of has_one must be primary key ? Here is my relation: Model_A: id, B_id, .... has_one:
    key_from => B_id
    model_to => Model_B
    key_to => id Model_B: id, ......

    when I forge a model: $a = Model_A::forge()
    $a->b = Model_B::forge()
    $a->save() it shows error:
    the "B_id" field of A can't be null but ..... shouldn't "B_id" of A be assigned to the same value of "id" of B automatically?
    i.e. ORM should do this: $a->B_id = $a->b->id; can anyone help me?
    Thanks!
  • Have you set the $_belongs_to relationship in Model_B?
  • Peter wrote on Thursday 19th of July 2012:
    Have you set the $_belongs_to relationship in Model_B?
    Yes, but still failed === I found a solution, Set Model_A belongs_to Model_B rather than "has_one" Model_B,
    then the problem is solved!

Howdy, Stranger!

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

In this Discussion