Wiki articles tagged with "relations"

Showing 1-8 of 8 items.

Working with relational removals by yii2

Created 7 years ago by AndroideLP, updated 7 years ago by Jairus Martin.

This tutorial shows you how to safely remove records between relationships.

0 0
2 followers
Viewed: 36 696 times
Version: 2.0
Category: Tutorials

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

Created 9 years ago by le_top, updated 9 years ago by le_top.

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.

1 0
2 followers
Viewed: 14 388 times
Version: 1.1
Category: How-tos

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

Created 10 years ago by thiagoc7, updated 10 years ago by thiagoc7.

I could make this work following same useful tips from this post.

0 0
6 followers
Viewed: 65 547 times
Version: 2.0
Category: How-tos

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

Created 12 years ago by skworden, updated 11 years ago by skworden.

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.

3 1
6 followers
Viewed: 59 819 times
Version: 1.1
Category: How-tos

Accessing data in a join table with the related models

Created 12 years ago by fsb, updated 12 years ago by krowe.

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.

16 1
30 followers
Viewed: 147 663 times
Version: 1.1
Category: How-tos

Searching and sorting by related model in CGridView

Created 12 years ago by Maciej Liżewski, updated 10 years ago by Kostas Apazidis (KonApaz).

Lets say we have two models and relation between them:

77 0
93 followers
Viewed: 276 849 times
Version: 1.1
Category: Tutorials

1:n relations sometimes require CDbCriteria.together

Created 12 years ago by fsb, updated 10 years ago by fsb.

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.

15 0
12 followers
Viewed: 51 991 times
Version: 1.1
Category: Tips

Relations: BELONGS_TO versus HAS_ONE

Created 13 years ago by Steve Friedl, updated 11 years ago by Jorgee.

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.

56 0
35 followers
Viewed: 164 748 times
Version: 1.1
Category: FAQs