我们约定每张表必须对应一个模型,还是以示例模块为例,以上一步的文章分类表example_cate为例,应该在actionphp/application/example/model目录下创建模型文件Cate.php,文件内容如下: ![](https://box.kancloud.cn/bcfd54230105013bbb320a3252dab47d_831x580.png) 注意`namespace app\core\cate;`、`class Cate extends Common`和`protected $table = 'ia_example_cate';`需要根据实际情况修改。 ``` <?php /** * +---------------------------------------------------------------------- * | InitAdmin/actionphp [ InitAdmin渐进式模块化通用后台 ] * +---------------------------------------------------------------------- * | Copyright (c) 2018-2019 http://initadmin.net All rights reserved. * +---------------------------------------------------------------------- * | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) * +---------------------------------------------------------------------- * | Author: jry <ijry@qq.com> * +---------------------------------------------------------------------- */ namespace app\core\cate; use app\core\model\Common; use think\Model; use think\model\concern\SoftDelete; class Cate extends Common { // 设置当前模型对应的完整数据表名称 protected $table = 'ia_example_cate'; public static function init() { parent::init(); } // 软删除 use SoftDelete; protected $deleteTime = 'delete_time'; protected $defaultSoftDelete = 0; } ```