I am trying to retrieve data from table having many to many relationships between user and projects and I want to retrieve and display projects by user id. I am trying to execute following code for this but I receive object not defined error.I am taking help from reference document http://www.yiiframework.com/doc/guide/1.1/en/database.dao:
$connection=Yii::app()->db;
$user = Yii::app()->user->getId();
$rows= $connection->createCommand()->select('*')->from('tbl_project_user_assignment')->
where(‘user_id=:id’,array(’:id’=>Yii::app()->user->getId()))->queryAll();
//$rows=$command->execute();
foreach($rows as $row){
//process each item here
$pid=$row['project_id'];
$rows2= Yii::app()->db->createCommand()->select('*')->from('tbl_project')->where('id=:pid',array(':pid'=>$pid))->queryAll();
//$rows2=$command2->execute();
echo CHtml::encode($rows2->id);
echo CHtml::encode($rows2->name);
echo CHtml::encode($rows2->description);
echo CHtml::encode($rows2->create_time);
echo CHtml::encode($rows2->create_user_id);
echo CHtml::encode($rows2->update_time);
echo CHtml::encode($rows2->update_user_id);