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

 $model=$this->loadModel($condition);

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

http://www.yiiframework.com/doc/guide/1.1/en/database.arr

thanks

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


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

	'id'=>'game-grid',

        'type'=>'striped bordered condensed',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

        'template'=>"{items}",

                'columns'=>array(

                    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…

$data->theRelation->categoryType;

http://www.yiiframework.com/forum/index.php/topic/10185-using-relations-and-conditions/