如何CI框架AR數(shù)據(jù)庫操作常用函數(shù)-創(chuàng)新互聯(lián)

本篇文章為大家展示了如何CI框架AR數(shù)據(jù)庫操作常用函數(shù),內容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。

網站建設哪家好,找創(chuàng)新互聯(lián)!專注于網頁設計、網站建設、微信開發(fā)、重慶小程序開發(fā)、集團企業(yè)網站建設等服務項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了永登免費建站歡迎大家使用!

1、查詢表記錄

$this->db->select();  //選擇查詢的字段
$this->db->select_max();
$this->db->select_min();
$this->db->select_avg();
$this->db->select_sum();
$this->db->from();   //選擇表名
$this->db->join();
$this->db->get();   //得到查詢結果
$this->db->get_where();
$this->db->where();
$this->db->or_where();
$this->db->where_in();
$this->db->or_where_in();
$this->db->where_not_in();
$this->db->or_where_not_in();
$this->db->like();
$this->db->or_like();
$this->db->not_like();
$this->db->or_not_like();
$this->db->group_by();
$this->db->distinct();
$this->db->having();
$this->db->or_having();
$this->db->order_by();
$this->db->limit();
$this->db->count_all_results();

2、增加表記錄

$this->db->insert();

3、更改表記錄

$this->db->set();
$this->db->update();

4、刪除表記錄

$this->db->delete();

5、清空表記錄

$this->db->empty_table();
$this->db->truncate();

6、緩存部分

$this->db->start_cache()
$this->db->stop_cache()
$this->db->flush_cache()

7、結果結果集

result()  //返回對象數(shù)組
result_array() //返回二維數(shù)組
row()   //返回一個對象
row_array()  //返回一維數(shù)組
num_rows()  //返回查詢的行數(shù)
num_fields() //返回查詢結果的字段數(shù)
free_result() //釋放查詢所占的資源內存

8、輔助查詢函數(shù)

$this->db->insert_id()  //獲取剛剛插入的id
$this->db->affected_rows() //修改或插入影響的行數(shù)
$this->db->count_all();  //統(tǒng)計記錄的總條數(shù) 這一函數(shù)加入where條件無效
$this->db->last_query();  //最后一條執(zhí)行的sql語句
//注意以下兩個函數(shù)僅返回sql語句 不執(zhí)行sql語句
$data = array('name' => $name, 'email' => $email, 'url' => $url);
$str = $this->db->insert_string('table_name', $data);
$data = array('name' => $name, 'email' => $email, 'url' => $url);
$where = "author_id = 1 AND status = 'active'";
$str = $this->db->update_string('table_name', $data, $where); //返回正確格式的更新字符串

PS:關于CodeIgniter詳細使用技巧可參考本站在線手冊:

CodeIgniter 2.2.4用戶指南:
http://shouce.jb51.net/codeigniter2.2/

CodeIgniter 3.0用戶指南:
http://shouce.jb51.net/codeigniter3.0/

上述內容就是如何CI框架AR數(shù)據(jù)庫操作常用函數(shù),你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

分享文章:如何CI框架AR數(shù)據(jù)庫操作常用函數(shù)-創(chuàng)新互聯(lián)
鏈接URL:http://www.muchs.cn/article38/depesp.html

成都網站建設公司_創(chuàng)新互聯(lián),為您提供電子商務建站公司、云服務器、虛擬主機、標簽優(yōu)化、小程序開發(fā)

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

綿陽服務器托管