A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

载入database,
?
1
2
3
$this->load->database();
也可在config文件夹下的autoload.php文件中修改:
$autoload['libraries'] =array('database');

这样,就可以使用了。
查询单条数据:
?
1
2
3
4
5
$this->db->select('title, content, date');
$query=$this->db->get_where('test',array('id'=>$id));
//$this->db->where('id', $id);
//$query = $this->db->get('test');
return$query->row_array();

查询多条数据:
?
1
2
3
4
5
6
$this->db->select('title, content, date');
$query=$this->db->get('test');
//$this->db->from('test');
//$query = $this->db->get();
$this->db->order_by("title","desc");
return$query->result_array();

获取数据库中的记录总数:
?
1
2
3
4
$this->db->count_all(‘test');

$this->db->where('aid',$aid);
return$this->db->count_all_results('test');


1 个回复

倒序浏览
奈斯,感谢分享
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马