时间:2021-07-01 10:21:17 帮助过:186人阅读

使用前提:
ThinkPHP6 数据库和模型操作已经独立为ThinkORM库
要使用Db类必须使用门面方式( think\facade\Db )调用
数据库操作统一入口: Db::
引入类:
use think\facade\Db;
1.query 方法用于执行 MySql 查询操作
<?php $sql="SELECT * FROM `shop_goods` where status=1"; $query = Db::query($sql); print_r($query); ?>
2.execute 方法用于执行 MySql 新增和修改操作
<?php
$execute = Db::execute("INSERT INTO `shop_goods` VALUES (3, 1)");
print_r($execute);
$execute = Db::execute("UPDATE `shop_goods` set `price`='1100' where `id`=3 ");
print_r($execute);
?>推荐:《Thinkphp6》《PHP视频教程》《最新的10个thinkphp视频教程推荐》
以上就是TP6中的原生MySql语句的详细内容,更多请关注gxlcms其它相关文章!