User - Admin or guest

I am using the authenticate function in the UserIdentity component to check a users details in the database. This works fine. In my database table User I have a column called admin (0 = guest 1 = admin). How do I set this in this function, then call it in my scripts to determine if the user has admin privliages (1) or guest privlages (0).

public function authenticate()


{





	$user=User::model()->find('LOWER(email)=?',array(strtolower($this->username)));


	if($user===null)


		$this->errorCode=self::ERROR_USERNAME_INVALID;


	else if(!$user->validatePassword($this->password))


		$this->errorCode=self::ERROR_PASSWORD_INVALID;


	else


	{


		$this->_id=$user->userId;


		$this->username=$user->email;


		$this->errorCode=self::ERROR_NONE;


	}


	return $this->errorCode==self::ERROR_NONE;





}

$user=User::model()->find(...);

$rights = $user->admin;

are you sure it works?


$user=User::model()->find('LOWER(email)=?',array(strtolower($this->username)));

Yeah is there anything you might think is wrong with that?

http://www.yiiframework.com/doc/cookbook/60/

I’m about parameters in find method. I usually write something like this:


$user = User::model()->find(array(

	'condition' => 'LOWER(email) = :email',

	'params' => array(':email' => strtolower($this->username)),

));

But if it works no difference :)

@Ted:

Hehe, i thought i’ve read this syntax somewhere in the guide - but i guess i was wrong. The only place this way of passing parameters is mentioned seems to be in the API docs for bindParam/bindValue which are used by AR internally. So, that’s why this works, too. Just curious, can you tell where you learned this syntax?