Yii Rights: Get all assigned roles of a user

$command = Yii::app()->db->createCommand("SELECT * FROM `authassignment` WHERE userid={$user_id}");
$results = $command->queryAll();
$roles = array();
foreach ($results as $result)
{
    $roles[] = $result['itemname'];
}
$this->setState('roles', $roles);

Author: Tahir Yasin

Tahir is a Passionate Web Developer from Lahore, Pakistan and a guy with NEVER-STOP-LEARNING attitude who keeps an eye on emerging technologies and customer trends.

Leave a Reply

Your email address will not be published. Required fields are marked *