I am having PHP class
class SurveyQuestion extends CActiveRecord
{
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'surveyOptions' => array(self::HAS_MANY, 'SurveyOptions', 'surveyQuestion_id'),
'survey' => array(self::BELONGS_TO, 'Survey', 'survey_id'),
);
}
}
and in controller, I want to get list of surveys with its options, so I am doing..
$this->renderJson(array('success'=>true, 'message'=>'Records Retrieved Successfully',
'data'=>SurveyQuestion::model()->with('surveyOptions')->findAll()));
but when this controller method is getting called, I am getting this error..
include(SurveyOptions.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory
As per http://www.yiiframework.com/doc/guide/1.1/en/database.arr, I should be able to get response with options in each survey.
I think, inclue(SurveyOptions.php) should be SurveyOption.php (without ‘s’) but
I am not able to see what is wrong?
After reading your comments, you just need to change your relation :
Since your class name is
SurveyOptionand file is SurveyOption.php