包含文件 use thinkDb;
public function index3() { $result=Db::execute('insert into ceshi (name,paw)VALUE ("李四","234")');//添加数据 print_r($result); $result=Db::execute('update ceshi set name="王五" where id=3');//修改数据 print_r($result); $result=Db::query('delete from ceshi where id=3');//删除数据 $result=Db::query('select * from ceshi ');//查询数据 print_r($result); $result=Db::query('show tables from tptest');//显示数据库列表 print_r($result); $result=Db::query('truncate table ceshi');//清空表数据 print_r($result); $result=Db::connect('db1')->query('select * from ceshi');//查询两个数据库数据需要配置 $result=Db::connect('db2')->query('select * from ceshi');//查询两个数据库数据需要配置 Db::table('ceshi') ->insert(['id'=>1,'name'=>'张三','paw'=>'123']); Db::table('ceshi') ->where('id',1) ->update(['name'=>'李四']); print_r( Db::table('ceshi') ->where('id',1) ->select()); Db::table('ceshi') ->where('id',1) ->delete(); }