Hi all,
I have a question about relation types.
What are differences between hasMany and BelongsTo? I am not sure after reading http://www.chronoengine.com/faqs/72-ccv5/5218-adding-1-more-belongsto-model-to-our-connection.html
HasOne is 1:1
hasMany is 1:N
but BelongsTo ?
thx
I have a question about relation types.
What are differences between hasMany and BelongsTo? I am not sure after reading http://www.chronoengine.com/faqs/72-ccv5/5218-adding-1-more-belongsto-model-to-our-connection.html
HasOne is 1:1
hasMany is 1:N
but BelongsTo ?
thx
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
Regards,
Max
Sorry, But I dont understand what u mean by Master or slave model. could u be pls more specific?
thx
thx
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
Regards,
Max
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).
for example, user (master) can have unlimited count of comments (slave).
Yes, but in this case you will get 4 records loaded, 1 for each comment, with the same user record!
This topic is locked and no more replies can be posted.