Declare set_group_id() function as following in student model page
public static function set_group_id($id)
{
$val= Yii::app()->db->createCommand()->select('Group_Name')->from('m_student_group')->where('Group_Id=:$id')->queryAll(array('index'=>'Group_Name'));
var_dump($val);
return $val->Group_Name;
}
Now it shows following error.
CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':$id' at line 3. The SQL statement executed was: SELECT `Group_Name`
FROM `m_student_group`
WHERE Group_Id=:$id
In the above sql query instead of $id put hard code value (say 52) then it shows error
Hi Balu, for your kind information i am already written the following code in student.php model page of student page.
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(
'Ledger' => array(self::BELONGS_TO, 'StudentGroup', 'Group_Id'),
);
}
But and wrote the following code at studentGroup.php model page of studentgroup.
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(
'Group' => array(self::HAS_MANY, 'Student', 'Group_Id'),
);
}