Creating simple model

There is two kinds CFormModel and CActiveRecord

But if I dont want to use form on this model and dont want a.r. just need to access db the DAO way, what should I extend?

or I don’t need to extend any thing?

cause the db access is via Yii::app()->db so I have all what I need…

extends from CModel;

When attributeNames are used?

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…

So this is the way I’ll go

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;		

}



In yii you have Yii::app()->db this is a CDbConnection instance and than you can use dao or query builder or what ever.

I just need the separation to make it “mvc” :lol: and not VC ::)