problem in working with database

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);

[color="#006400"]/* Moved from "2.0" to "1.1" */[/color]

queryAll() doesn’t return an array of model objects, but an array of arrays representing the rows.




echo CHtml::encode($rows2['id']);



If you are new to Yii, I strongly recommend you to start with Yii 2.0, not 1.1. :)