网站地图    收藏   

主页 > 后端 > codeigniter >

CodeIgniter数据库的使用

来源:未知    时间:2015-04-22 09:50 作者:xxadmin 阅读:

[导读] 载入database, $this-load-database(); 也可在config文件夹下的autoload.php文件中修改: $autoload[libraries] =array(database); 这样,就可以使用了。 查询单条数据: $this-db-select(title, content, date); $query=...

载入database,
 
$this->load->database();
也可在config文件夹下的autoload.php文件中修改:
$autoload['libraries'] =array('database');
这样,就可以使用了。
查询单条数据:
 
$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();
查询多条数据:
 
$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();
获取数据库中的记录总数:
 
$this->db->count_all(‘test');
$this->db->where('aid',$aid);
return$this->db->count_all_results('test');
 

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论