//result() 返回對象數(shù)組$data = $ " /> 香港经典三级成人xxx,女性一级全黄生活片免费看,黄片毛片免费

一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

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

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

復制代碼 代碼如下://查詢:
$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() 返回查詢結果行數(shù)
$data = $query->num_rows();

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

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

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

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

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

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

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

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

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

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

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

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

//更新數(shù)據(jù),被更新的數(shù)據(jù)會被自動轉換和過濾,例如:
//$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ù)為別名,相當于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技術codeigniter數(shù)據(jù)庫操作函數(shù)匯總,轉載需保留來源!

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

主站蜘蛛池模板: 日韩中文字幕亚洲无线码 | 国产视频一区二区在线观看 | 亚洲第一区精品日韩在线播放 | 色在线网站 | 日韩大胆人体 | 久久精品国产无限资源 | 婷婷网五月天天综合天天爱 | 91区国产福利在线观看午夜 | 激情15p| 91在线网址| 亚洲一区二区三区麻豆 | 免费播放欧美一级特黄 | 亚洲吊丝网 | 男人扒开女人腿使劲桶动态图 | 欧美激情图区 | 久久国产精品国产自线拍免费 | 我要看三级全黄 | 真人午夜a一级毛片 | 欧美一区二区三区gg高清影视 | 呦呦国产 | 五月亭亭激情五月 | 精品久久久99大香线蕉 | 精品哟哟哟国产在线观看不卡 | 久久精品国产屋 | 成人小视频在线播放 | 日本福利在线观看 | 欧美裸妇 | 一本一本久久a久久综合精品蜜桃 | 精品国产免费一区二区 | 在线观看中文字幕国产 | 97在线视频精品 | 狠狠色噜噜狠狠狠狠97不卡 | 久久国产麻豆 | 狠狠综合久久久综合 | 香蕉97超级碰碰碰碰碰久 | 在线观看国产小视频 | 99在线视频免费观看 | 激情丁香网| 天堂一区二区三区精品 | 天天添天天操 | 成人综合久久精品色婷婷 |