1
在控制器我写以下无法查看findBySql导致
$types=Types::model()->findBySql('SELECT t_id, t_name FROM ygs_types');
$this->render('index', array('types'=>$types));
鉴于
$list = CHtml::listData($types, 't_id', 't_name');
foreach($list as $type) {
echo '<p>'.$type.'</p>';
}
,但我看不到任何结果。
如果我在控制器
$typeModel = new Types();
$types = $typeModel->findAll();
$this->render('index', array('types'=>$types));
写我看到的结果列表。 该查询无误。
谢谢,它帮助! – ETartaren 2015-02-07 17:12:10