thinkphp6---原生SQL查询
2022/9/8 2:24:34
本文主要是介绍thinkphp6---原生SQL查询,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
最近开发项目,由于要考虑大数据的处理,对比了一下,使用Thinkphp执行SQL语句的效率,要比使用模型来做大数据的更新,效率要高很多。
总结:复杂的运算,以及对大数据的查询,更新,建议使用SQL语句:
1、query 查询方法
Db::query("select * from think_user where status=:id", ['id' => 1]); Db::query("select * from think_user where status=:id", ['id' => 1], true);
2、execute 更新/读写方法
Db::execute("update think_user set name='thinkphp' where status=1"); Db::query("select * from think_user where id=? AND status=?", [8, 1]); Db::execute("update think_user set name=:name where status=:status", ['name' => 'thinkphp', 'status' => 1]);
参考:
https://www.kancloud.cn/manual/thinkphp6_0/1037570
打完收工!
这篇关于thinkphp6---原生SQL查询的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-29env: php: no such file or directory
- 2024-03-01php foreach break
- 2024-02-26Exception参数 php-icode9专业技术文章分享
- 2023-12-30PHP文件批量上传-icode9专业技术文章分享
- 2023-12-30thinkphp6 withJoin-icode9专业技术文章分享
- 2023-12-27MagicArray:像php一样,让Go业务代码不再卷!
- 2023-11-18centos7编译安装PHP教程。
- 2023-11-18centos7编译安装phpMyAdmin教程。
- 2023-10-13唱衰这么多年,PHP 仍然还是你大爷!
- 2023-07-25PHP8,性能更好,语法更好,类型安全更完善