in my fist aplication in yiii how i crate a model whit no database
Posted 05 May 2011 - 03:19 PM
So let’s build our model and controller, if you’re confused on how to do this, type help within the shell to get the specifics. For the controller, add the additional actions of show and edit. Once completed, you can see where all the files were created and you can even use the test link to view your web application template in your web server. I used Message as my ID for everything but feel free to put String or HelloWorld or whatever suits you. With your Model, type Form after ID, so it looks like YourIDForm.
Now in your favourite coding software, open up the following files:
so my question is can i build a model with no database configured o table in the database?
Posted 05 May 2011 - 04:47 PM
Yes you can create a model even if you don't have any database. If you take a look at the CModel Class Reference, you will se that CModel has 2 subclasses :
- CActiveRecord : this one is used to work with database
- CFormModel : this one is used to work with forms
In the explanation you've inserted in your post, the author refers to a CFormModel.
Hope this helps
Posted 05 May 2011 - 06:01 PM
Posted 06 May 2011 - 06:35 AM
Maybe the best solution would be to create it from an existing CFormModel. For instance you can have a look to the blog demo which is delivered with the Yii framework (check the <YII_FRAMEWORK_HOME>\demos\blog folder). This is a good starting point if you want to learn Yii. Go to the protected/models folder and open ContactForm.php or LoginForm.php. They both inherit from CFormModel and consequently don't require any database.
Gii or yii shell is nice, but to really understand what's going on behind the scene, IMHO it is better to do it manually first.
hope this helps