Get Data From Two Tables

Hi. I’m new in PHP world and I have some doubts. My main question is how can I get the data from an administrator for a situation update? I have two tables for user data:

table ‘Admin’: idAdmin

table ‘User’: idUser, Name, Email, Password, etc…

The two tables are linked as follows: idAdmin = idUser

When an admin want to change your data, I have to get the data from User where idUser is equals to idAdmin, but how do I this condition in php? I was doing:

 $condition=new CDbCriteria;

 $condition->condition='User::model()->idUser=:Admin::model()->idAdmin AND User::model()->idUser=:$this->$id';


But it don’t work… :( anyone can help me?

First a simple question: why do you have to table for managing users?

you can always refer to the guides here is the link to relational active record


other example of this my problems: at a view named ‘game’, I have

$this->widget('bootstrap.widgets.TbGridView', array(


        'type'=>'striped bordered condensed',





                    array('name'=>'idgame', 'header'=>'#', 'url'=>array('view', 'id'=>$model->idgame)),

                    array('name'=>'name', 'header'=>'Game'),

                    //array('name'=>'category' , 'header'=>'Category'),

                    //array('name'=>'username', 'header'=>'Autor'),

                    array('name'=>'dateInsertion', 'header'=>'Date inserted'),

                    array('name'=>'dateUpdate', 'header'=>'Last update'),




this $model is from table ‘game’, but the value ‘category’ is from table ‘Category’ and the value ‘username’ is from table ‘Users’.And how I put that values here?

You can use relation between the table…