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。

步骤1-打开CRUD Generator界面,填写表格。

Gii-创建模型

步骤2-然后,单击“预览”按钮,然后单击“生成”。转到URL http:// localhost:8080 / index.php?r = my-user,您将看到所有用户的列表。

Gii-创建模型

步骤3-打开URL http:// localhost:8080 / index.php?r = my-user / create。您应该看到用户创建表单。

Gii-创建模型

作者:terry,如若转载,请注明出处:https://www.web176.com/yii/337.html

(0)
打赏 支付宝 支付宝 微信 微信
terryterry
上一篇 2020年10月23日 下午2:57
下一篇 2020年10月23日 下午3:13

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注