😌Working with Databases, Database Migration Full (ok)
https://www.yiiframework.com/doc/guide/2.0/en/start-databases
1. Creating Migrations
2. Create Model


Hoặc chúng ta có thể sử dụng dòng lệnh cmd

3. Create Migrate Database

C:\xampp72\htdocs\testcom\console\migrations\m130524_201442_init.php
C:\xampp72\htdocs\testcom\console\migrations\m230321_083107_default_user.php
Kết quả:


4. 1. Create a table post

C:\xampp72\htdocs\testvn\common\models\Post.php
C:\xampp72\htdocs\testcom\console\migrations\m230321_084018_post.php
Kết quả:


4. 2. Create a table category
Lợi dụng bảng đã có sẵn use ta khai báo gii như sau để tạo 1 model

Rồi sau đó thay đổi attribute theo ý mình
C:\xampp72\htdocs\testcom\common\models\Category.php

C:\xampp72\htdocs\testcom\console\migrations\m230321_085655_category.php
Kết quả:

4. 3. Create a table comments

C:\xampp72\htdocs\testcom\console\migrations\m230321_091626_comments.php
C:\xampp72\htdocs\testcom\common\models\Comment.php
Kết quả đạt được


4. 4. Create a table tag




Kết quả:



4. 5. Create a table tag_post


C:\xampp72\htdocs\testcom\console\migrations\m230321_093310_tag_post.php
Kết quả
C:\xampp72\htdocs\testcom\common\models\TagPost.php
Preparing the Database
Configuring a DB Connection
Creating an Active Record: C:\xampp74\htdocs\oectest\models\Country.php
Creating an Action: C:\xampp74\htdocs\oectest\controllers\CountryController.php
Creating a View: C:\xampp74\htdocs\oectest\views\country\index.php
Trying it Out: https://oec.test/?r=country%2Findex or https://oec.test/?r=country


Last updated