1、原生sql语句。
Db::query(‘select * from think_user where id=?’,[8]);
Db::execute(‘insert into think_user (id, name) values (?, ?)’,[8,‘thinkphp’]);
2、查询构造器
不同的辅助操作,先后顺序没影响。
Db::table(‘banner’)->where(‘id’, ‘>’, ‘2’)->order(‘update_time asc’)->select();
Db::table(‘banner’)->order(‘update_time asc’)->where(‘id’, ‘>’, ‘2’)->select();
find,select,insert,update,delete 是放在最后的,中间的顺序无所谓。
find是得一条数据,select是多条。支持链式操作。
3、模型 (ORM Object Relation Mapping 对象关系映射)
就是通过模型来映射到我们的数据库中的表,然后通过操作模型来操作数据库
飞软教育 php学习之thinkphp5 总结第五天
最新推荐文章于 2024-01-22 16:14:29 发布