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[...]