Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Call to a member function implode_pk() on a non-object
  • The full contents of the error message I am getting:
    ErrorException [ Error ]: Call to a member function implode_pk() on a non-object
    PKGPATH/orm/classes/model.php @ line 730

    This is happening when trying to associate a new "Product" with a "Category".
    If I don't add a category, I don't get the error message. The Category:
    protected static $_has_many = array(
            'products' => array(
                'key_from' => 'category',
                'model_to' => 'Uploader\Model_Offer',
                'key_to' => 'category',
                'cascade_save' => true,
                'cascade_delete' => false,
            )
        );
    

    The Product:
    protected static $_belongs_to = array(
            'category' => array(
                'key_from' => 'category',
                'model_to' => 'Uploader\Model_Category',
                'key_to' => 'category',
                'cascade_save' => true,
                'cascade_delete' => false,
            )
        );
    

    It sort of came out of nowhere and the only backtrace is COREPATH/bootstrap.php @ line 36. I'm trying to figure out what changed in this module, but I'm struggling to do so. Any ideas?
  • You can't have a relation and a column property with the same name. Since you define 'category' as a key, I assume that's a column name in both tables. Which means you can't have a relation called 'category', as that would make $model->category ambigious.
  • Harro.. once again you have saved the day.
    I will adjust that and see if it changes the result. Update: It worked.
    Thanks again for bringing out the common sense.

Howdy, Stranger!

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

In this Discussion