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