Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Problems with relations : implode_pk() exception
  • Hello everyone,
    First congrats the community for this awesome framework, I am really in love with it !

    Lately, I encountered a strange problem, I explain it:

    I have the follow models:

    Model_Folder {
            [.....]
    protected static $_has_many = array(
            'subfolders' => array(
    'model_to'  => 'Model_Folder',
    'key_to'    => 'parent_id',
    'key_from'  => 'id',
            ),
    'translations'    => array(
    'model_to'      => 'Model_Translation',
    'key_to'           => 'token',
    'key_from'        => 'transl_token',
    'cascade_save'  => true, 
    'cascade_delete'=> true
    ));

    }

    Model_Translation {
          
    protected static $_properties = array(
    'id',
    'lang' ,
    'token' , 'key' , 'value');

    }

    So, Model_Folder is related with its childrens (subfolders), and translations to translate some of its fields.

    The problem is that when I fetch a single folders, if it is a deepest children (starting from the 4th level ), I get an exception from :

    /orm/classes/model.php @ line 877
    Call to a member function implode_pk() on a non-object

    I can only say this is happening when I translate something of the folder  and so the folder when fetching related translations throw this error.
    If the folder has not translations I can fetch it without problem.

    Also the other folders from 1st to 3rd level , if they have translations I can fetch them without problems.

    It's a bit strange, some of you know why it's happening?
    Hope you understand the problem , I am Italian , and maybe my english isn't good !
    Greets
  • Sorry my error, I did not tested appropriately all cases, but now the problem happens with all subfolders . So briefly if I am getting a folder (only with translations) , which is children of another folder I get that error.

  • HarroHarro
    Accepted Answer
    Can you change your ORM installation to 1.8/develop, and see if it still is a problem?
  • HarroHarro
    Accepted Answer
    Also, relations always have to be defined both ways, and it looks like your Model_Translation doesn't have a belongs_to relation back to Model_Folder?
  • @Harro Verton You're right, Model_Translation has not the belongs_to relation.
    I resolved changing ORM to 1.8/develop ! Thanks

    I share, what I discovered about the behavior of this error. 

    When I was fetching the folder, in that case for editing it on the form, I was also selecting all folders to put inside a select menu, to choose one of them as parent of the folder I am editing on the form.
    I tried to delete temporary the select of all the folders with all related childrens, and I was not getting the error, and translations were correctly fetched . 

    The case was: if the Folder had not translations I could query all the folders for the select menu, instead if I didn't query two times the Folder model , I could get the related translations.

    So there was definitively a problem handling maybe twice the the two relations.



Howdy, Stranger!

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

In this Discussion