Reputation: 4508
I'm trying to get used to relational active record but things look too complicated for now. If it's not difficult please point me in right direction.
I have 4 tables.
Users
userID[pk],userName
Cars
car_id[pk],userID[fk to Users],car_nickname,make_id[fk to Makes],model_id[fk to Models]
Makes
make_id[pk],make_name
Models
model_id[pk],model_name,make_id[fk to Makes]
Now input data is userName,make_name,model_name
and task is to get car_nickname from Cars table.
Is this possible using relations or should I do it step by step checking makes,models,users for IDs and then puting all IDs into Cars to get car_nickname ?
Upvotes: 0
Views: 48
Reputation: 326
You can yous only one Model with reliations to all tables. And create one _form.php in the Views, where there will only fields you need.
Some halpfull information. if you save some data into some table and you need saved data id
, you caN use $newid = $model->getPrimaryKey();
and assign to new variable , wich will save into other tables.
I think this is short way to solve problem
Upvotes: 1