新建application/index/model/School.php
内容
namespace app\index\Model;
use think\Model;
use think\Db;
class School extends Model {
public $db;
function __construct(){
$this->db=Db::name('school');
}
public function getSchool($where="del=0"){
return $this->db->where($where)->select();
}
}
新建application/index/controller/Test.php用于测试
namespace app\index\controller;
use think\Loader;
class Test extends Common
{
public function index(){
$a=Loader::model('school')->getSchool();
print_r($a);
}
}
标签:index,调用,自定义,getSchool,db,application,TP5,php,where
来源: https://blog.csdn.net/L_Taozi/article/details/88868369