컨트롤러에서 나는 다음과 같이 씁니다.
$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));
결과 목록이 표시됩니다. 쿼리가 정확합니다.
아래와 같이 findAllBySql
대신 사용해야 findBySql
합니다.
$types=Types::model()->findAllBySql('SELECT t_id, t_name FROM ygs_types');
이제 원하는 결과를 볼 수 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다