If I extend CModel I need to implement it ,because CModel is abstract
can I just leave it blank? what is his role?
I think I should create Model That extends CModel, because the abstractness of CModel and the attributeNames method that not implemented will cause me to create a lot of additional code in every custom model…
being an apprentice i can not give you much help, but this function could be some sort of hint?
Yii doesn’t want the users to use direct database operations, not safe, not efficient. these operations are all encapsulated into CDbConnection and CDbCommand.
public function isUserInRole($role)
{
$sql="select role from tbl_project_user_role where project_id=:projectId and user_id=:userId and role=:role";
$command=Yii::app()->db->createCommand($sql);
$command->bindValue(":projectId",$this->id, PDO::PARAM_INT);
$command->bindValue(":userId",Yii::app()->user->getId(), PDO::PARAM_INT);
$command->bindValue(":role",$role, PDO::PARAM_STR);
return $command->execute()==1?true:false;
}