Gii-모델 생성
Gii에서 모델을 생성하려면-
<?php
namespace app\models;
use app\components\UppercaseBehavior;
use Yii;
/**
* This is the model class for table "user".
*
* @property integer $id * @property string $name
* @property string $email
*/
class MyUser extends \yii\db\ActiveRecord {
/**
* @inheritdoc
*/
public static function tableName() {
return 'user';
}
/**
* @inheritdoc
*/
public function rules() {
return [
[['name', 'email'], 'string', 'max' => 255]
];
}
/**
* @inheritdoc
*/
public function attributeLabels() {
return [
'id' => 'ID',
'name' => 'Name',
'email' => 'Email',
];
}
}
?>
CRUD 생성
MyUser 모델에 대한 CRUD를 생성하겠습니다.
Step 1 − CRUD 생성기 인터페이스를 열고 양식을 작성합니다.

Step 2− 그런 다음 "미리보기"버튼과 "생성"을 클릭합니다. URL로 이동http://localhost:8080/index.php?r=my-user, 모든 사용자 목록이 표시됩니다.

Step 3 − URL 열기 http://localhost:8080/index.php?r=my-user/create. 사용자 생성 양식이 표시되어야합니다.
