i have a table in database known as modules
it’s struscture is
id(primary key)
display_name(module name)
parent_id(the parent of the module where the parent id 0 shows that the module is the parent module) and the level is upto 3 that is
I have the
Parent module
child mochdule
subchild module
every child module belongs to a parent and subchile belongs to a child module
now i am using
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(
'groupmodule'=>array(self::HAS_ONE, 'UserGroupsModulesNew', 'parent_id'),
'childmodule'=>array(self::BELONGS_TO, 'UserGroupsModulesNew', 'parent_id'),
);
}
when i run the query it returns the correct result and number of rows but when i retreive the result it only shows one result or row …I am using this in case of update view where the id condition gets concatinated in the where clause
please help me out
2)also when i use findall
public function actionUpdate($id)
{
$model=$this->loadModel($id);
$allmodules=$this->getAllModules();
echo '<pre>';
print_r($allmodules);
$mainmodules=CHtml::listData($allmodules,'id','display_name');
$this->render('update',array('model'=>$model,'mainmodules'=>$mainmodules));
}
public function loadModel($id, $scenario = false)
{
$model=array();
$model=UserGroupsModulesNew::model()->with('groupmodule')->with('childmodule')->findAll('t.id=:id',array(':id'=>$id));
if($model===null)
throw new CHttpException(404,Yii::t('userGroupsModule.general','The requested page does not exist.'));
if ($scenario)
$model->setScenario($scenario);
return $model;
}
I get errors like get_class() expects parameter 1 to be object, array given
Please help me out i have spent around 3 days …the forum has got slow i don’t know why but last 7 to 8 posts are unanswered no one bothers…i hope i’ll get a reply