新建application/index/model/School.php
内容
<?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用于测试
<?php namespace app\index\controller; use think\Loader; class Test extends Common { public function index(){ $a=Loader::model('school')->getSchool(); print_r($a); } }