Skip to main content

模型定义

一、模型定义

app/models 下新建 model 文件。

model 文件推荐命名规则和表名一致,例如:student 表 命名 model 文件为 Student.php

二、文件内容定义

2.1 继承 Model

use core\base\Model;

2.2 定义表名

protected $tables = 'student';

2.3 重写父类构造方法

示例
public function __construct()
{
parent::__construct($this->tables);
}

三、示例

示例
<?php
namespace app\models;

use core\base\Model;
class Student extends Model
{
protected $tables = 'student';

public function __construct()
{
parent::__construct($this->tables);
}
}