目录
user.php 模型创建
<?php
namespace app\model;
//引用Model
use think\Model;
//模型文件和数据表名称相同
class User extends Model
{
// 添加模型(UserModel)后缀需要设置模型名称
// protected $name = 'user';
// 设置主键
// protected $pk = 'id';
// 设置表
// protected $table = 'tp_user';
// 初始化操作
// protected static function init()
// {
// parent::init();
// }
// 是否严格却分字段大小写
// protected $strict = false;
// 设置字段类型 减少内存开销 推荐下面方式设置字段类型
// 1. php think optimize:schema 会在runtime下面生成schema文件
// 2. 在config/database.php 下开启字段换成
// protected $schema = [
// 'id' => 'int',
// 'username' => 'string',
// 'password' => 'string',
// 'gender' => 'string',
// 'email' => 'string