Wiki

Articles tagged with "relations", sorted by ratingX
Displaying 1-5 of 5 result(s).

Searching and sorting by related model in CGridView

Created about a year ago by redguyTutorials49 comments – viewed 63,141 times – ( +78 )
Lets say we have two models and relation between them:

Relations: BELONGS_TO versus HAS_ONE

Created 2 years ago by Steve FriedlFAQs7 comments – viewed 40,965 times – ( +59 )
It's very common to see new Yii users confusing the relations HAS_ONE and BELONGS_TO, and getting it wrong means you won't get proper values back. And though we'll talk about HAS_MANY as well, we're specifically omitting the MANY_MANY relation because it's a whole different animal.

1:n relations sometimes require CDbCriteria.together

Created about a year ago by fsbTips4 comments – viewed 14,557 times – ( +13 )
There are situations in which Active Record will generate nonsense queries from what a nieve Yii user might think is reasonable code. One such situation is a CActiveDataProvider using CDbCriteria to get data from parent and 1:n child table with a condition on the child table.

Accessing data in a join table with the related models

Created about a year ago by fsbHow-tos7 comments – viewed 38,468 times – ( +18 / -1 )
Sometimes the right place to store application data is in a join table. For example, movie viewers either like or don’t like the movies they watched.

Cheat Sheet: Displaying Name instead of Numbers and Displaying Alphanumeric instead of numeric values

Created 7 months ago by skwordenHow-tos4 comments – viewed 6,094 times – ( +3 / -1 )
I keep a reference to some simple but painful task if you forget a common or something. I am new to Yii and this took awhile for me to figure out. Everything I read said do this or do that and not a single one worked for me. However, the following did.