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...
Page 1 of 1
Creating simple model
#1
Posted 24 September 2011 - 06:28 AM
Certification:

Test Yii:
Yii Framework Demos
Wiki:
Common Yii Questions
Tutorials:
Demo Blog Search with Zend_Lucene
Fundamentals:
Yii "registry" | Understanding the layout->view randering flow
Etc:
Shrink Yii | Caching config/main.php | CPhpAuthManager - how it works, and when to use it
Extensions:
Theme Picker | Language Picker (i18n)

Test Yii:
Yii Framework Demos
Wiki:
Common Yii Questions
Tutorials:
Demo Blog Search with Zend_Lucene
Fundamentals:
Yii "registry" | Understanding the layout->view randering flow
Etc:
Shrink Yii | Caching config/main.php | CPhpAuthManager - how it works, and when to use it
Extensions:
Theme Picker | Language Picker (i18n)
#3
Posted 24 September 2011 - 06:51 AM
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
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
Certification:

Test Yii:
Yii Framework Demos
Wiki:
Common Yii Questions
Tutorials:
Demo Blog Search with Zend_Lucene
Fundamentals:
Yii "registry" | Understanding the layout->view randering flow
Etc:
Shrink Yii | Caching config/main.php | CPhpAuthManager - how it works, and when to use it
Extensions:
Theme Picker | Language Picker (i18n)

Test Yii:
Yii Framework Demos
Wiki:
Common Yii Questions
Tutorials:
Demo Blog Search with Zend_Lucene
Fundamentals:
Yii "registry" | Understanding the layout->view randering flow
Etc:
Shrink Yii | Caching config/main.php | CPhpAuthManager - how it works, and when to use it
Extensions:
Theme Picker | Language Picker (i18n)
#4
Posted 24 September 2011 - 07:31 AM
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.
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;
}
Yii, powerful yet difficult to harness.
#5
Posted 24 September 2011 - 07:35 AM
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"
and not VC
I just need the separation to make it "mvc"
Certification:

Test Yii:
Yii Framework Demos
Wiki:
Common Yii Questions
Tutorials:
Demo Blog Search with Zend_Lucene
Fundamentals:
Yii "registry" | Understanding the layout->view randering flow
Etc:
Shrink Yii | Caching config/main.php | CPhpAuthManager - how it works, and when to use it
Extensions:
Theme Picker | Language Picker (i18n)

Test Yii:
Yii Framework Demos
Wiki:
Common Yii Questions
Tutorials:
Demo Blog Search with Zend_Lucene
Fundamentals:
Yii "registry" | Understanding the layout->view randering flow
Etc:
Shrink Yii | Caching config/main.php | CPhpAuthManager - how it works, and when to use it
Extensions:
Theme Picker | Language Picker (i18n)
Share this topic:
Page 1 of 1

Help














