如果你对该文章中的内容有疑问/不解,可以点击此处链接提问
要注明问题和此文章链接地址 点击此处跳转
use think\Db; $info = Db::table('fly_user')->select();//用些前缀,全部查询 $info = Db::table('fly_user')->find();//用写前缀,单条查询 $info = Db::name('user')->select();//不用写前缀 dump($info); Db::query('select * from think_user where id=?',[8]); Db::execute('insert into think_user (id, name) values (?, ?)',[8,'thinkphp']);
model ---model/Index.php <?php namespace app\index\model; use think\Model; class Index extends model { protected $table = 'fly_user'; protected $pk = 'id'; public function index1() { $info = $this->get(1); return $info->data; } } controller-----controller/Index.php $userinfo = model('index'); $info = $userinfo->index1(); dump($info);