加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

CI框架AR数据库操作常用函数总结

发布时间:2020-12-12 21:52:49 所属栏目:PHP教程 来源:网络整理
导读:本篇章节讲解CI框架AR数据库操作常用函数。供大家参考研究具体如下: 1、查询表记录 db->select(); //选择查询的字段$this->db->select_max();$this->db->select_min();$this->db->select_avg();$this->db->select_sum();$this->db->from(); //选

本篇章节讲解CI框架AR数据库操作常用函数。分享给大家供大家参考,具体如下:

1、查询表记录

db->select(); //选择查询的字段 $this->db->select_max(); $this->db->select_min(); $this->db->select_avg(); $this->db->select_sum(); $this->db->from(); //选择表名 $this->db->join(); $this->db->get(); //得到查询结果 $this->db->get_where(); $this->db->where(); $this->db->or_where(); $this->db->where_in(); $this->db->or_where_in(); $this->db->where_not_in(); $this->db->or_where_not_in(); $this->db->like(); $this->db->or_like(); $this->db->not_like(); $this->db->or_not_like(); $this->db->group_by(); $this->db->distinct(); $this->db->having(); $this->db->or_having(); $this->db->order_by(); $this->db->limit(); $this->db->count_all_results();

2、增加表记录

db->insert();

3、更改表记录

db->set(); $this->db->update();

4、删除表记录

db->delete();

5、清空表记录

db->empty_table(); $this->db->truncate();

6、缓存部分

db->start_cache() $this->db->stop_cache() $this->db->flush_cache()

7、结果结果集

8、辅助查询函数

db->insert_id() //获取刚刚插入的id $this->db->affected_rows() //修改或插入影响的行数 $this->db->count_all(); //统计记录的总条数 这一函数加入where条件无效 $this->db->last_query(); //最后一条执行的sql语句 //注意以下两个函数仅返回sql语句 不执行sql语句 $data = array('name' => $name,'email' => $email,'url' => $url); $str = $this->db->insert_string('table_name',$data); $data = array('name' => $name,'url' => $url); $where = "author_id = 1 AND status = 'active'"; $str = $this->db->update_string('table_name',$data,$where); //返回正确格式的更新字符串

PS:关于CodeIgniter详细使用技巧可参考本站在线手册:

CodeIgniter 2.2.4用户指南:

CodeIgniter 3.0用户指南:

更多关于CodeIgniter相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》、《》、《》及《》

希望本文所述对大家基于CodeIgniter框架的PHP程序设计有所帮助。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读