By using the more “advanced” way of declaring the relations in the models you can set table name, relation name, foreign key column name, related model name and in the case many to many: also the relation table (and both of the foreign keys).
If you omit any of the settings (except for the tablename), the default values will be used for those settings omitted.
This is covered in the manual, so I’ll post an example:
class project extends IgnitedRecord{
var $__id_col = 'pk'; // primary key (default: id)
var $__has_one = array('table' => 'supervisors',
'col' => 'supervisorid'); // foreign key column name
var $__has_and_belongs_to_many =
array( // multiple relations
array('table' => 'developers',
'rel_table' => 'project_assignments', // tablename for the table storing the relations
'this_col' => 'projectid', // the foreign key column in the relation table referring to this table
'other_col' => 'developerid' // the foreign key column in the relation table referring to the related table
),
'clients' // just use all defaults
);
function project(){
parent::IgnitedRecord();
}
}
Currently my lib does not autodetect primary key name, personally I think it isn’t needed (the __id_col property is fine).
I think I will implement some methods to change the relation settings (methods are needed because they are sanitized/normalized, not needed for the rest of the properties, so you can add/remove/edit relations during runtime), but currently you can change them in the property declarations (if you look at the constructor in IgnitedRecord, you can maybe modify the relations yourselves during runtime, but I’ll make some methods soon).