Creating CRUD's and how too

I was hoping for some basic help. The idea is that I like is that I can use the gii to create the pages and models and the controllers needs for my web app. The only thing I don’t know is that how just the gii works. From what I been able to tell is that the model reads the table fields and then creates the required forms and controllers from the tables in the database. So I take it that naming the table fields the right way would give me the right result. I hope. I been doing some searching and I haven’t fount a thing on this. YET. The idea is guys is too build an web app related to the tables and fields from a database. How ever if I don’t name them right. I mean the table fields right. The controllers and forms will not work or look like they should.

I general. Making an article section.

As a lot of you know that articles require a lot of info.



Image or 2

Attachment file. If any any

A brief info

and the article content. and that could have images and formatted text.

date created

date modified and so on.

So what I been tried to figure out is how to name the table fields to get what I want. Does any one have a list of how to name table fields. So that I can get the right results when I use gii.


The choice of table names is more a database design consideration and doesn’t really have any great affect on how gii does it’s magic. Did you read the getting started guide and go through the blog tutorial? There’s also plenty of resources on the net about database design so you might want to take a look at them too.

Good luck


Yes I did. How ever the resources I did find didn’t give me the information I needed. Any ideas. Or maybe a list or a web site that may have add on modules would help too.

Larry Ullman’s tutorial might be helpful.

Especially the following 2 articles deal with database design and CRUD.

#4 of 8 : Defining Databases for the Yii Application

#5 of 8 : Creating Models, Views, and Controllers in Yii

I advise you to read up these pages in the guide. They provide you with the most basic information in quite some detail to get you started. After that you can take a look at the wiki which has additional resources on more advance topics. I’ve been true them my self and they contain all information that you are requesting.

softark, Thank you. I all ready read threw this and well he only gives one small sample and that he doesn’t give a list of the table field names and what gii will create when it reads the tables. For a sample let’s do this

Lets say I wanted to add a field name called image. Does gii know what this is for. and how to code it. I all ready tried this and it didn’t work.

The idea is that a list of the naming conventions for the table fields is not to be fount. gii is not going to know what the table field is use for if you don’t have a way to tell gii what to do with it.

So if I add a table field called image1, image2 and so on. Then gii needs to know that this is an image upload. So that when it creates the pages. and the controller. It has to know that this is an image upload. The upload paths have to be defined. and then the record is saves. The upload image has to be view when the user views this record.

Get the idea. Same thing with a file upload. If I posted a message in a blog or in a article and I wanted to attach a file to that article. Nothing I have tried works.

I do have Larry Ullman’s books on yii. and well he missing a lot of information in his books. I haven’t been able to read all the way threw them yet.

Gii generates most of the boilerplate code needed for models / controller / views hence a basic crud operations. What you want is a more complex scenario which is not included in the basic setup.

For adding a file upload feature to your form you can check out this tutorial

Keep in mind yii is a framework which handles most of the basics, but still you will need to write code your self to handle more complex scenario’s.

That’s why I’m having an hard time. See I have done some OOP before. Just nothing as complex as yii. and I’m so new to this. It would take me years to figure it out. Or find some one who could do some tutoring. Like that will happen. I just can’t a ford to pay for help sense this is a personal project. I do know that the support for yii is very limited.

or I would need modules for all the parts I need to get the results. and I all ready checked and this web site doesn’t even have 1/2 of them. So I guess I am better off staying with basic OOP coding.

Thanks for your time.