Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Upgrading Fuelphp from 1.3 to 1.8.2 - Two Issues
  • 1. Orm/classes/model.php update() throwing error
    Required to change in add_primary_keys_to_where() Fuel/packages/orm/classes/model.php
    For some reason code line throwing error for undefined index 'id' which is my primary key to table.
    $query->where($pk, '=', $this->_original[$pk]);
    So I changed it to old 
    $query->where($pk, '=', $this->_data[$pk]);

    2. Related table ID is not coming.
    For Model Model_Order I have _has_many relation as follow
    protected static $_has_many = array(
    'products' => array(
    'key_from' => 'id',
    'model_to' => '\\Invoice\\Model_Product',
    'key_to' => 'order_id',
    'cascade_delete' => true,
    'cascade_save' => true

    When I try to get them as $order->products(), this returns all products without primary key
  • $query->where($pk, '=', $this->_original[$pk]);
    So I changed it to old 
    $query->where($pk, '=', $this->_data[$pk]);

    Doing this is dangerous, as you don't take the retrieved value, but the possibly updated one. Besides that, _data is copied from _original when the record is loaded, so I don't see how 'id' can be missing from it?

    Your second problem seems related to the first.

    You don't have some classes overloaded by any chance?

    You might also want to try develop, it has a log of bug fixes, it might be an issue already solved.
  • hi, I have one interface implemented.
    class Repository_Product extends \Repository_Base implements Interface_Product.

    Just for note, code was working fine in version 1.3
  • You're making a large leap in versions, I can't comment on what the code does.

    I've never seen an ORM object with fields mssing, unless select() is used (which should be avoided), and in that case it should be missing from both _data and _original.
  • This is my code, I was getting error on $order->save();
    $order = $this->model;
  • Difficult to comment without knowing exactly what you do.

    You need to debug your code, and see what goes wrong and fix any compatibility issues when upgrading the framework. Changing the framework to adapt to your (now) incorrect code is the wrong way around.

Howdy, Stranger!

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

In this Discussion