I have 2 tables:
Trip - id, PortID, StartDate, EndDate
Port - id, LookupID, Name, Description
PortID is a foreign key, which links to the LookupID (not the ID, please don’t ask why). ID on Port is the primary key.
Is there any way to automatically generate the BELONGS::TO relation for Port correctly? At the moment, it just ignores that foreign key - and it is because LookupID is not a primary key I believe.
Why you need it generated automatically? You can always correct it in the relations() definition in the model.
It should work if the FK is properly defined in the database. What db do you use?
I know I can edit the model manually, I don’t want to though … I am in the process of writing a set of templates that will be run using giic to generate the models and crud. The database I do not have full control over - it is legacy and it is structured as I explained. Because the foreign key is pointing to a field that is not the primary key, gii will not generate the relations code for it. I am using MS SQL SERVER … in itself not an issue, I have used it previously with Yii.
Please put your realations() code.
Maybe you have to define the key manually if you can detect it by your giic module.