thinkphp 链接数据库
<?php namespace app\index\controller; use think\Db; class Demo4 { public function conn1() { return Db::table('daohang')->where('id',1)->value('title'); } public function conn2() { return Db::connect([ 'type'=>'mysql', 'hostname'=>'127.0.0.1', 'database'=>'ceshi', 'username'=>'root', 'password'=>'root', ]) ->table('admin') ->where('id',1) ->value('username'); } }