yii2.0在model里自定义数据表

无需多言,直接撸代码

class Zhuanjia extends \yii\db\ActiveRecord
{
    public static function tableName()
    {
        return 'tableName';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name', 'type', 'phone'], 'required'],
            [['status'], 'integer'],
            [['name'], 'string', 'max' => 60],
            [['type', 'phone'], 'string', 'max' => 255]
        ];
    }
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'type' => 'Type',
            'phone' => 'Phone',
            'status' => 'Status',
        ];
    }
}

 

  

posted @ 2017-11-23 10:17  山上小和尚  阅读(680)  评论(0编辑  收藏  举报