Articles tagged with "relations", sorted by date (updated)X
Displaying 1-8 of 8 result(s).

Working with relational removals by yii2

Updated 4 months ago by AndroideLPTutorials0 comments – viewed 4,785 times – version 2.0
This tutorial shows you how to safely and safely remove relationships between relationships and multiple lines.

Relation scope to test existence of related records ("EXISTS")

Updated 2 years ago by le_topHow-tos0 comments – viewed 5,367 times – ( +1 ) – version 1.1
When one needs to select a record in a table that do not have related records through a relation, it is generally suggested to use a subquery. Personnaly, I prefer a high level approach, and I have a method to do it with scopes.

Book Has Author - Many to Many relations using Kartik\Select2

Updated 2 years ago by thiagoc7How-tos2 comments – viewed 14,275 times – ( +3 ) – version 2.0
I could make this work following same useful tips from this post.

Searching and sorting by related model in CGridView

Updated 2 years ago by Kostas Apazidis (KonApaz)Tutorials86 comments – viewed 192,399 times – ( +126 ) – version 1.1
Lets say we have two models and relation between them:

1:n relations sometimes require CDbCriteria.together

Updated 3 years ago by fsbTips5 comments – viewed 38,093 times – ( +16 ) – version 1.1
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.

Relations: BELONGS_TO versus HAS_ONE

Updated 3 years ago by JorgeeFAQs9 comments – viewed 122,933 times – ( +69 ) – version 1.1
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.

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

Updated 4 years ago by skwordenHow-tos4 comments – viewed 19,357 times – ( +4 / -1 ) – version 1.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.

Accessing data in a join table with the related models

Updated 4 years ago by kroweHow-tos8 comments – viewed 108,763 times – ( +28 / -1 ) – version 1.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.