PHP-CodeIgniter数据库部分的函数

$this->load->databases()  数据库连接

$this->load->reconnect() 重新连接

$this->load->close()  手动关闭数据库连接


$query=$this->load->query($sql) 查询

$query=$this->load->simple_query() 上面一个查询函数的简化版本

$this->load->escape()转义查询

$this->load->escape_str()

$this->load->escape_like_str()

$query->result() 返回对象数组

$query->result_array()将记录集作为关联数组返回

$query->row()第一行作为object返回

$query->row(num) 返回第n行(n从0开始)

$query->row_array() 功能和$query->row()一样但是返回的是数组

$query->first_row()  (object类型的)

$query->last_row() object类型的)

$query->next_row() (object类型的)

$query->previous_row()(object类型的)


$query->num_rows() 返回行数

$query->num_fields() 返回字段数

$query->free_result()  释放内存,删除相关的资源标识


查询辅助函数

$this->db->insert_id() 插入时的id

$this->db->affected_rows() 显示被更新或插入后影响的行数

$this->db->count_all() 返回指定表的总记录行数

$this->db->platform()  显示数据库平台(mysql ms sql...)

$this->db->version()

$this->db->last_query() 上次的查询语句

$this->db->insert_string() 根据提供的参数,生成insert语句

$this->db->update_string() 根据提供的参数,生成update语句


Active Record类

$$query->free_result() 释放内存,删除关联的资源标识


查询辅助函数
$this->db->get('tablename')

$this->db->get_where()

$this->db->select()

$this->db->select_max()

$this->db->select_min()

$this->db->select_avg()

$this->db->select_sum()

$this->db->select_from()  指定from的部分

$this->db->join()

$this->db->where()

$this->db->or_where()
$this->db->where_in()

$this->db->where_not_in()

$this->db->where_like()

$this->db->or_like()

$this->db->not_like()

$this->db->group_by()

$this->db->distinct()

$this->db->having()

$this->db->or_having()

$this->db->limit()

$this->db->count_all_result()



$this->db->insert()

$this->db->insert_batch()


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值