我试图从YII框架中的表中获取记录,不知道它为什么不起作用。
public function actionGetStarted($id) {
$curUser = new Customer;
$curUser->findByPk($id);
if (!$curUser)
throw new CHttpException(403, 'Customer Does\'t exists');
$getStarted = AppContent::model()->findAll();
$this->render('getStarted', array('getStarted' => $getStarted));
}
答案 0 :(得分:2)
你的语法不符合Yii。
public function actionGetStarted($id) {
$curUser = new Customer;
$user=$curUser::model()->findByPk($id);
e($curUser->attributes);// check this line.Also it seems incorrect
if (empty($user))
throw new CHttpException(403, 'Customer Does\'t exists');
// saving current customer to session
$getStarted = AppContent::model()->findAll();
$this->render('getStarted', array('getStarted' => $getStarted));
}