Relationships docs error

edited January 2014 in Share
There's an example in the docs where a relationship is defined without using the fuel_relationships table here and I think there is a closing bracket missing in the code?
public $has_many = array('attributes' => array('model' => array(FUEL_FOLDER => 'fuel_tags_model'), 'fuel_relationships_model' => 'my_relationship_model', 'foreign_key' => 'my_foreign_key', 'candidate_key' => 'candidate_key');

I'm trying to create a has_many relationship using the ion_auth models, so I would like the look-up table to be "users_groups", the candidate table to be "users" and the foreign table to be "groups". I've got the has_many property close to being correct, but the example above is throwing me.

I want something like:
$has_many = array('groups' => array('model' => array('app' => 'groups_model')), 'fuel_relationships_model' => 'users_groups_model'...

but I am running into problems defining the foreign_key and candidate_key - should the models be stated as well with these?

Comments

  • edited 9:57AM
    The models don't need to be stated. It's just the column names to be used in the specified lookup table. The lookup table should have at least 5 columns like the fuel_relationships table so I'm not sure if that will work with the current setup of ion_auth with some changes.

    MY_Model::relationship_field_names() method is where that mapping happens. If the fuel_relationships model lives in an advanced module folder (e.g. not the application directory), then you will need to use an array syntax with the key being the module and the value being the model. Also, the user_groups_model should inherit from MY_Model.
Sign In or Register to comment.