How to use Yii Framework CGridView for Active Records with Relations

When use CGridView to display Active Records with relationship, we should notice some points For CGridView’s Columns properties, you should use ‘relation[property]’ as your columns name (e.g. user[nick]). Or this column name will be fillet by CDataColumn::renderFilterCellContent() defined in Yii/zii/widgets/grid/CDataColumn.phps . (refer code strpos($this->name,'.')==false conditions normally in line 94). use $data->relation->property as CGridView’s Column’s value property. such as value=>'$data->user->nick' Create your search condition into Model’s search method by visit $_GET variable....

November 20, 2013 · 1 min

Yii的AR使用多数据库

Yii的Active Record模型中,数据库联接是通过getDbConnection()来获取的。 默认情况下,该函数返回的是配置文件中的c...

October 24, 2013 · 1 min