//result() 返回對象數(shù)組$data = $ " /> 精品综合网,久久久久九九九九,午夜av成人

四虎精品视频-四虎精品成人免费网站-四虎黄色网-四虎国产视频-国产免费91-国产蜜臀97一区二区三区

codeigniter數(shù)據(jù)庫操作函數(shù)匯總

網(wǎng)上倒是有不少Codeigniter數(shù)據(jù)庫操作的介紹,這里做一個(gè)匯總。

復(fù)制代碼 代碼如下://查詢:
$query = $this->db_query("SELECT * FROM table");
 ==================================

//result() 返回對象數(shù)組
$data = $query->result();

//result_array() 返回?cái)?shù)據(jù)
$data = $query->result_array();

//row() 只返回一行對象數(shù)組
$data = $query->row();

//num_rows() 返回查詢結(jié)果行數(shù)
$data = $query->num_rows();

//num_fields() 返回查詢請求的字段個(gè)數(shù)
$data = $query->num_fields();

//row_array() 只返回一行數(shù)組
$data = $query->row_array();

//free_result() 釋放當(dāng)前查詢所占用的內(nèi)存并刪除關(guān)聯(lián)資源標(biāo)識
$data = $query->free_result();

/*
 ==================================
 插入操作
 ==================================
*/

//上次插入操作生成的ID
echo $this->db->insert_id();

//寫入和更新操作被影響的行數(shù)
echo $this->db->affected_rows();

//返回指定表的總行數(shù)
echo $this->db->count_all('table_name');

//輸出當(dāng)前的數(shù)據(jù)庫版本號
echo $this->db->version();

//輸出當(dāng)前的數(shù)據(jù)庫平臺
echo $this->db->platform();

//返回最后運(yùn)行的查詢語句
echo $this->db->last_query();

//插入數(shù)據(jù),被插入的數(shù)據(jù)會被自動轉(zhuǎn)換和過濾,例如:
//$data = array('name' => $name, 'email' => $email, 'url' => $url);
$this->db->insert_string('table_name', $data);

/*
 ==================================
 更新操作
 ==================================
*/

//更新數(shù)據(jù),被更新的數(shù)據(jù)會被自動轉(zhuǎn)換和過濾,例如:
//$data = array('name' => $name, 'email' => $email, 'url' => $url);
//$where = "author_id = 1 AND status = 'active'";
$this->db->update_string('table_name', $data, $where);

/*
 ==================================
 選擇數(shù)據(jù)
 ==================================
*/

//獲取表的全部數(shù)據(jù)
$this->db->get('table_name');

//第二個(gè)參數(shù)為輸出條數(shù),第三個(gè)參數(shù)為開始位置
$this->db->get('table_name', 10, 20);

//獲取數(shù)據(jù),第一個(gè)參數(shù)為表名,第二個(gè)為獲取條件,第三個(gè)為條數(shù)
$this->db->get_where('table_name', array('id'=>$id), $offset);

//select方式獲取數(shù)據(jù)
$this->db->select('title, content, date');
$data = $this->db->get('table_name');

//獲取字段的最大值,第二個(gè)參數(shù)為別名,相當(dāng)于max(age) AS nianling
$this->db->select_max('age');
$this->db->select_max('age', 'nianling');

//獲取字段的最小值
$this->db->select_min('age');
$this->db->select_min('age', 'nianling');

//獲取字段的和
$this->db->select_sum('age');
$this->db->select_sum('age', 'nianling');

//自定義from表
$this->db->select('title', content, date');
$this->db->from('table_name');

//查詢條件 WHERE name = 'Joe' AND title = "boss" AND status = 'active'
$this->db->where('name', $name);
$this->db->where('title', $title);
$this->db->where('status', $status);

//范圍查詢
$this->db->where_in('item1', 'item2');
$this->db->where_not_in('item1', 'item2');

//匹配,第三個(gè)參數(shù)為匹配模式 title LIKE '%match%'
$this->db->like('title', 'match', 'before/after/both');

php技術(shù)codeigniter數(shù)據(jù)庫操作函數(shù)匯總,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 刘洋演员| 男女拔萝卜免费视频| 忍石| 伊利亚| 智乐星中考| 1987年美国电影| 电影《邪》在线观看| 不纽扣的女孩| 佐藤亚璃纱| 老爸的筒子楼 电视剧| 质量教育培训的首要内容是() (单选题)| 电影《stag》完整版| 抗日电影完整版| 秀人网门户网免费| 都市频道节目表| 真的爱你中文谐音歌词| 斯维特拜克之歌电影| 特种部队电影全集观看| 惊天十二小时| 乔治爸爸去哪儿| 幼儿园玩具| 横冲直撞好莱坞| 欲海情缘| 性色视频| 红男红女| 沙漠电影高清在线播放| 想要女朋友菲律宾| 晕车喝什么饮料能缓解| 日本电视剧《阿信》 | 梦想建筑师泰国百合剧| 七年级地理课时练电子版 | 还珠格格演员表| 财税2010121号原文| 电影五十度黑| 川岛海荷| 六年级上册英语书翻译| 艳妇乳肉豪妇荡乳ⅹxxo| 叶子楣喜剧电影全集| 疯狂试爱四| 火辣监狱在线观看| 绿巨人2|