Forums

relation types

Max_admin 27 Jun, 2014
Answer
belongs to is used when the model belongs to another 1, its a reversed 1:1 or 1:N, in other words, you use this when you are working on the "slave" model, and use hasOne or hasMany when you are working with the "master" model.

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
admin_wiky 30 Jun, 2014
Sorry, But I dont understand what u mean by Master or slave model. could u be pls more specific?
thx
Max_admin 30 Jun, 2014
Parent & Child, in a User > Profile relationship, the User would be the master and the Profile a slave, or User > Comment, but in some situations, you may want to start the relation with "Profile" instead of User, and in this case you need to use "belongsTo", because you are doing it in a reversed direction!

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
admin_wiky 22 Jul, 2014
I understand u now, but can I use BelongsTo if I have in slave table 4 records per 1 record in master?
for example, user (master) can have unlimited count of comments (slave).
Max_admin 23 Jul, 2014
Yes, but in this case you will get 4 records loaded, 1 for each comment, with the same user record!
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.