我正在尝试做的事情:我想使用 CGridView 打印表中的数据,但还有一件重要的事情 - 我需要将 $criteria 中的“bookId”的值更改为其他表中的“bookName”的值。
我怎样才能做到这一点?
问候。
/// here comes code from model
public function search() {
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria = new CDbCriteria;
$criteria->compare('bookId',$this->bookId);
$criteria->compare('bookBookdetailId', $this->bookBookdetailId);
$criteria->compare('bookState', 1);
return new CActiveDataProvider($this, array(
'criteria' => $criteria,
/// here is code from view
print_r($model);
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $model->search(), 'columns' => array(
'bookCatalgoueNumber',
'bookDescription',
'bookBookdetailId'
),
)
);
/// the name of the model is Book, the other is Bookdetail (and so are the tables)
/// 同样 bookBookdetailId 是链接到 Bookdetail.bookdetailId 的外键
// 我希望结果将书名 (bookdetailTitle) 替换为 bookBookdetailId