標籤:blog http os ar 資料 div sp log html
phpcms v9 資料庫操作函數
表明預設當前load_model(‘xxxx‘)模組所在表名xxxx
若要指定表名 則:操作在mysql.class.php中$this->db->select(...)
1、查詢
$this->select($where = ‘‘, $data = ‘*‘, $limit = ‘‘, $order = ‘‘, $group = ‘‘, $key=‘‘) 返回結果集數組
條件 ,欄位(id,name,email....),範圍 排序方式,分組方式,按建名排序
2、查詢多條資料並分頁
listinfo($where = ‘‘, $order = ‘‘, $page = 1, $pagesize = 20, $key=‘‘, $setpages = 10,$urlrule = ‘‘,$array = array())
3、擷取單條記錄查詢
get_one($where = ‘‘, $data = ‘*‘, $order = ‘‘, $group = ‘‘)
4、直接執行sql查詢
query($sql);
5、擷取最後一次添加記錄的主鍵號 insert_id()
6、執行更新記錄操作 update($data, $where = ‘‘) $data 建議為數組,$where 可為數組可為字串
7、執行刪除記錄操作 delete($where)
8、計算記錄數 count($where = ‘‘)
9、擷取最後資料庫操作影響到的條數 affected_rows()
10、擷取資料表主鍵 get_primary()
11、擷取表欄位 get_fields($table_name = ‘‘)
12、檢查表是否存在 table_exists($table)
13、 檢查欄位是否存在 field_exists($field)
phpcms v9 資料庫操作函數