Difference between #4 and #5 of
1:n relations sometimes require CDbCriteria.together

Revision #5 has been created by fsb on Jan 10, 2014, 2:48:38 PM with the memo:

code formatting
« previous (#4)

Changes

Title unchanged

1:n relations sometimes require CDbCriteria.together

Category unchanged

Tips

Yii version unchanged

Tags unchanged

CActiveDataProvider, cdbcriteria, together, cdbcriteria.together, 1:n, has_many, relations, active record

Content changed

[...]
People are in table `person` and phones in table `phone`. Each person can have zero, one or more phones. Phones can exist without being owned by anyone. So `phone` has a _non-identifying_ 1:n relation to `person`.

~~~
[sql]
CREATE TABLE person (
id INT NOT NULL PRIMARY KEY

 
);

CREATE TABLE phone (
[...]
CONSTRAINT fk_phone_person
FOREIGN KEY (person_id) REFERENCES person (id)
ON DELETE SET NULL

 
    
ON UPDATE RESTRICT
 
);
~~~


### The view
[...]
15 0
12 followers
Viewed: 51 997 times
Version: 1.1
Category: Tips
Written by: fsb
Last updated by: fsb
Created on: Dec 1, 2011
Last updated: 10 years ago
Update Article

Revisions

View all history