引入 use/think/Db;
query 用于查询 其他的用execute
插入记录
$result = Db::execute(‘insert into sb_ad (ad_name, ad_content ,status) values (1, “456”,1)’);
dump($result);
更新记录
$result = Db::execute(‘update sb_ad set ad_name = “framework” where ad_id = 1 ‘);
dump($result);
查询数据
$result = Db::query(‘select * from sb_ad where ad_id = 1’);
print_r($result);
删除数据
$result = Db::execute(‘delete from sb_ad where ad_id = 2 ‘);
dump($result);
其它操作
显示数据库列表
$result = Db::query(‘show tables from tpshop1’);
print_r($result);
清空数据表
$result = Db::execute(‘TRUNCATE table sb_ad’);
dump($result);