- Open yii code generator - http://localhost/webappname/index.php?r=gii/default/login
- Select Crud Generator and enter the name of your model you created in the Model Generator.
It should be noted that the use of uppercase and lowercase letters should be tailored to the name of the Model Class we have made to the Model Generator. In the previous example the discussion of Model Generator, Model name is its Class User (letter U in the word using the letters of the user). And select preview and cetang all existing Code File and click generate.
On Crud Generator you will see the results on protected\views\user\
generated controllers\UserController.php
generated views\user\_form.php
generated views\user\_search.php
generated views\user\_view.php
generated views\user\admin.php
generated views\user\create.php
generated views\user\index.php
generated views\user\update.php
generated views\user\view.php
- To view the results please click on try it now or go on http://localhost/webappname/index.php/user
- To operate the CRUD (Create-Read-Update-Delete), you must first login. Open http://localhost/webappname/index.php/site/login
- Then go again http://localhost/webappname/index.php/user/. You can see there is not a user.
- Have you gone to http://localhost/webappname/index.php/user/create. to create a new user - Create User
- If you have made, you can see it back in http://localhost/webappname/index.php/user/index - User List
- To Manage User (Create-Read-Update-Delete), you can open it in http://localhost/webappname/index.php/user/admin - Manage Users (View, Update, Delete)
Home » Posts filed under Gii Tool - Yii Code Generator
Showing posts with label Gii Tool - Yii Code Generator. Show all posts
Showing posts with label Gii Tool - Yii Code Generator. Show all posts
Monday, January 9, 2012
How to Use Crud Generator (Gii Tool - Yii Code Generator)
After I have discussed previously the Controller of making post "How to Use Controller Generator (Gii Tool - Yii Code Generator)" and also the model on the post "How to Use Model Generator (Gii Tool - Yii Code Generator)", I would go again in How to Use Crud Generator (Gii Tool - Yii Code Generator). CRUD (Create Read Update Delete) generator generates a controller and views that implement CRUD operations for the specified data model. Please follow these steps below to use this generator:
Yii Framework Tutorials
Sunday, January 8, 2012
How to Use Controller Generator (Gii Tool - Yii Code Generator)
Once we have made previous models in the example application of Model Generator (Gii Tool - Yii Code Generator), we proceed again on making the controller. Controller Generator helps you to quickly generate a new controller class, one or several controller actions and their corresponding views. The following implementation steps Controller Generator (Gii Tool - Yii Code Generator)
- Login to Gii - http://localhost/webappname/index.php?r=gii/default/login
- Then click on the menu Controller Generator - http://localhost/webappanme/index.php/gii/controller
- Fill Controller ID with a user (in accordance with the table we have made)
- Click preview and then generate.
Generating code using template "D:\xampp\htdocs\yii\framework\gii\generators\controller\templates\default"... generated controllers\UserController.php generated views\user\index.php done!
- Click to try it now or go to this link http://localhost/webappname/index.php/user, and see the results
Wednesday, December 28, 2011
How to Use Model Generator (Gii Tool - Yii Code Generator)
Model Generator, generates a model class for the specified database table. In the application of Gii Tool - Model Generator you need a database to connect. Follow the steps below:
1. Create a simple MySQL database. For example I use yiicode as database name and user as table. See the attributes as follows:
To make it, open http://localhost/xampp/, click on phpMyAdmin, click Databases, on the columns Create a new database typing demo, and click create. After that click on the SQL and create a user table by entering the following SQL command:
2. After that you please login to Gii - http://localhost/webappname/index.php?r=gii/default/login.
Typing in the Table Name * is tbl_user and in the Model Class * is User
You can see PHP code by click Preview button and the models\User.php. This code will be automatically stored in the xampp \ htdocs \ yourappname \ protected \ models \ User.php.
After it, click the Generate button
If successful will appear in the following:
1. Create a simple MySQL database. For example I use yiicode as database name and user as table. See the attributes as follows:
| Field | Type | Lenght/Values | Exrta | Primary |
| id | int | - | auto_increment | Yes |
| name | varchar | 60 | - | - |
| address | varchar | 200 | - | - |
| website | varchar | 100 | - | - |
| varchar | 50 | - | - |
To make it, open http://localhost/xampp/, click on phpMyAdmin, click Databases, on the columns Create a new database typing demo, and click create. After that click on the SQL and create a user table by entering the following SQL command:
CREATE TABLE user ( id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, name VARCHAR(60) NOT NULL, address VARCHAR(200) NOT NULL, website VARCHAR(100) NOT NULL, email VARCHAR(50) NOT NULL );
Typing in the Table Name * is tbl_user and in the Model Class * is User
You can see PHP code by click Preview button and the models\User.php. This code will be automatically stored in the xampp \ htdocs \ yourappname \ protected \ models \ User.php.
After it, click the Generate button
If successful will appear in the following:
The code has been generated successfully.That means you have successfully created a model to perform CRUD operations.
Generating code using template “xampp\htdocs\yii\framework\gii\generators\model\templates\default”…
generated models\User.php
done!
Subscribe to:
Posts (Atom)










