Open /protected/config/main.php
uncomment the following to enable the Gii tool:
|
|
'gii'=>array( 'class'=>'system.gii.GiiModule', 'password'=>'rajeev', // If removed, Gii defaults to localhost only. Edit carefully to taste. 'ipFilters'=>array('127.0.0.1','::1'), ), uncomment the following to use MySql db: 'db'=>array( 'connectionString' => 'mysql:host=localhost;dbname=db_sch_library', 'emulatePrepare' => true, 'username' => 'root', 'password' => '', 'charset' => 'utf8', ), |
Next you have to create a databse in mysql for your application and a table:
In my case it is db_sch_library, and table is books. The structure is given below:
|
|
CREATE TABLE books ( id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , title VARCHAR( 255 ) NOT NULL , description TEXT NOT NULL , isbn VARCHAR( 50 ) NOT NULL , price VARCHAR( 50 ) NOT NULL ) ENGINE = MYISAM ; |
Then you have to call the gii using browser like following:
http://localhost/sch_library/index.php?r=gii
Then it will ask for gii password, enter password
Then you will get a code generator page with following options:
1. Controller Generator
2. Crud Generator
3. Form Generator
4. Model Generator
5. Module Generator
Click on the like Model Generator
In the model generator page, you have to enter Table Name. The Model class will come automatically in the Model Class
text box. Click on Preview button. Then it will show the code file and Generate Button. Click on Generate button.
Then click on link Crud Generator, and it will ask for the Model Class name and Controller ID. Enter the Model name which
you have created earlier.The controller id will come automalically. Click on Preview button to preview the code files and
after that Click on Generate Button.
Then there will be a link “try it now”to see the result or you can browse like this:
http://localhost/<web_app_dir>/index.php?r=books
That’s it
Incoming search terms:
- crud android mysql framework
- crud en yiic mysql
- ios crud generator