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!
Thanks, very nice & easy to learn .. :)
ReplyDeleteHai,
ReplyDeleteIs it possible to store into our live databases by yii. I mean i want to store from data dynamically into our live databases(based on ipaddress). and i have to write query like insert into or update directly not by Gii.
So please forward if u have any queries or links to sk.ijaz@gmail.com.
Thanks
Wow! This could be one of the most useful blogs we have ever come across on thesubject. Actually excellent info! I’m also an expert in this topic so I can understand your effort. free nintendo eshop codes
ReplyDelete