Hi. I just started working on this framework. I have to make some changes to a user list.
So this is what i have:
//UserController.php
class UsuarioController extends Controller
{
public function actionAdmin()
{
if(Yii::app()->authManager->checkAccess('RUsuario', Yii::app()->user->getState("rol")))
{
$model=new Usuario('search_propios');
$model->unsetAttributes();
if(isset($_GET['Usuario'])) $model->attributes=$_GET['Usuario'];
$this->render('admin',array('model'=>$model,));
}
else
throw new CHttpException(401,'No tiene permisos de acceso al recurso URL.');
}
}
//Models -> User.php
class Usuario extends CActiveRecord
{
public static function model($className=__CLASS__)
{
return parent::model($className);
}
public function tableName()
{
return 'rc_usuario';
}
public function search_propios()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$idUsuarioActual = Yii::app()->user->getState('idWeb');
$criteria=new CDbCriteria;
$criteria->compare('idUsuario',$this->idUsuario);
$criteria->compare('nombre',$this->nombre,true);
$criteria->compare('apellidos',$this->apellidos,true);
$criteria->compare('email',$this->email,true);
$criteria->compare('web',$this->web,true);
$criteria->order='idWeb';
return new CActiveDataProvider($this, array('criteria'=>$criteria,));
}
}
Actually that list shows every user from rc_user.
What i need is to read from a table some id’s and show those id’s from users table, verifing that the connected login id matches.
So i have 2 tables: rc_user and rc_friend
rc_user -> ‘idUser’
rc_friend -> ‘idFriend’ and ‘idUser’
I need something like:
select * from rc_user where idUser = (select idFriend from rc_friend where idUser = $connectedUserID)
How can i do that?? Also to show some rc_friend columns in the list, that’s quite complicated, to me
Thanks!