Home > Database > Mysql Tutorial > codeigniter 操作mysql的PHP代码--更新_MySQL

codeigniter 操作mysql的PHP代码--更新_MySQL

WBOY
Release: 2016-05-31 08:47:51
Original
1065 people have browsed it

CI框架

1)查询不等于且有等于

$this->db->get_where('host',array('host'=>'ddd','id !='=>0))->row();
Copy after login

2)2表相交

return $this->db	->select('f.*,count(s.id) as subtotal')	->from('category as f')->join('category s', 'f.id=s.upid', 'left')	->where('f.upid', $upid)	->group_by('f.id')	->order_by('f.sort', 'asc')	->get()->result();
Copy after login

3)多个order_by 排序

return $this->db->select('*')	->from('v_category')	->where('upid',$upid)	->order_by('sort','asc')	->order_by('id','desc')	->get()->result();
Copy after login
4)单条记录
return $this->db->get_where('category', array('id' => $id))->row();
Copy after login

5)多条记录

return $this->db->get_where('v_category', array('upid' => $upid))->result();
Copy after login

更多稍后补充,转载请注明来自 default7#zbphp.com,欢迎交流。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template