Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在Yii框架中从模型中获取特定记录_Php_Yii - Fatal编程技术网

Php 如何在Yii框架中从模型中获取特定记录

Php 如何在Yii框架中从模型中获取特定记录,php,yii,Php,Yii,我正在尝试从YII框架中的表中获取记录,不知道为什么它不起作用 public function actionGetStarted($id) { $curUser = new Customer; $curUser->findByPk($id); if (!$curUser) throw new CHttpException(403, 'Customer Does\'t exists'); $getStarted = AppContent::mo

我正在尝试从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));
}

您的语法与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));
}