//result() 返回對象數(shù)組$data = $ " /> 国产欧美无码亚洲,美女张开让男生桶,国产产乱码一二三区别免费

天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

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

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

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

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

//result_array() 返回數(shù)據(jù)
$data = $query->result_array();

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

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

//num_fields() 返回查詢請求的字段個數(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();

//返回最后運行的查詢語句
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');

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

//獲取數(shù)據(jù),第一個參數(shù)為表名,第二個為獲取條件,第三個為條數(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');

//獲取字段的最大值,第二個參數(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');

//匹配,第三個參數(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)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 精品视频免费在线 | 成人国产在线视频 | 性一交一无一伦一精一品 | 久久麻豆亚洲AV成人无码国产 | 亚洲精品色情APP在线下载观看 | 607080老太太AW | 手机移动oa| 一道本无吗d d在线播放 | 久久黄视频| 欧美一区二区日韩一区二区 | 老司机亚洲精品影院 | 麻豆精品人妻一区二区三区蜜桃 | 国产精品自产拍在线观看网站 | 野花4在线观看 | 在线精品视频免费观看 | 九九久久国产精品免费热6 九九久久国产精品大片 | 国产亚洲精品高清视频免费 | 水蜜桃亚洲一二三四在线 | 日韩人妻无码精品-专区 | 少妇精品久久久一区二区三区 | 亚洲电影二区 | 91精品国产色综合久久不 | 国产成人自拍视频在线观看 | 快播官方网站 | 黄色免费网址在线观看 | 国产午夜精品自在自线之la | 岛国在线永久免费视频 | 日本妈妈在线观看中文字幕 | 日本xxx在线观看免费播放 | 翁公与小莹在客厅激情 | 婷婷亚洲AV色香蕉蜜桃 | 色琪琪无码成人AV视频 | 果冻传媒2021在线观看 | 亚洲精品日韩在线观看视频 | 91久久线看在观草草青青 | 亚洲AV久久无码精品国产网站 | 羞羞漫画免费漫画页面在线看漫画秋蝉 | 李丽莎与土豪50分钟在线观看 | 哪里能看毛片 | 九九在线中文字幕无码 | 97在线观看免费 |