Changes
Title
unchanged
two or more different collected data in one CGridView
Category
unchanged
How-tos
Yii version
unchanged
Tags
unchanged
merge, concatenate, different, columns, data, CGridView
Content
changed
Assume that you have teachers and students model.
```php
teacher model has:
- person_id,
- id_teacher,
- name,
- surname,
- bachelor,
- master,
... etc
student model has:
- person_id,
- id_student,
- name,
- surname,
- age,
- apartment
```
(person_id is a global id both of teacher
s and student
s)
Now we want a
n CArrayProvider like that
PERSON
S DETAILS[...]
}
//from merge with
e second data collection
$test = 0;
foreach ($t2 as $v) {
$res[$v->person_id] = array_merge(isset($res[$v->person_id]) ? $res[$v->person_id] : array(), $v->attributes);
}[...]