Difference between #2 and #3 of
Relations: BELONGS_TO versus HAS_ONE

Revision #3 has been created by Steve Friedl on Apr 26, 2011, 3:07:56 AM with the memo:

Minor wordsmithing
« previous (#2) next (#4) »

Changes

Title unchanged

Relations: BELONGS_TO versus HAS_ONE

Category unchanged

FAQs

Yii version unchanged

Tags unchanged

relations, HAS_ONE, BELONGS_TO

Content changed

[...]
PROFILE table
- id
- user_id REFERENCES User.id
- profile_info
~~~
**KEY POINT**: A `BELONGS_TO` relation says that a field in **this** model points to the primary key in **another** model; in this case,
_the current model owns the linking field_. **KEY POINT**: A `HAS_ONE` relation says that some **other** model has a linking field pointing to **this** model's primary key; in this case, _the related model owns the linking field_.

Let's put these in context (numbered for reference)

```php
// Post model relations
[...]
56 0
35 followers
Viewed: 164 744 times
Version: 1.1
Category: FAQs
Written by: Steve Friedl
Last updated by: Jorgee
Created on: Apr 26, 2011
Last updated: 11 years ago
Update Article

Revisions

View all history