解析用PHP操作MySql數(shù)據(jù)庫(3)_PHP教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
str = "";
for (i=start_p; i<=end_p; i++){
if (i==this->page){
str.= " <strong>".i."</strong> ";
}else{
str.= " <a href=’".this->url.i."’>".i."</a> ";
}
}
return str;
}
function show_page_info(){
str = " 共".this->total_records."條/".this->total_pages."頁";
return str;
}
function show_page(){
if (this->total_records<1){
this->set_show_page();
}
str = this->total_pages>1 ? this->show_first_prv().this->show_num_btn().this->show_next_last().this->show_page_info().this->show_num_text():"";
return str;
}
//總頁數(shù)
function set_total_pages(){
this->total_pages = ceil(this->total_records/this->page_size);
}
//總記錄數(shù)
function set_total_records(){
if (this->total_records==0 or !isset(this->total_records)){
if (empty(this->count_sql) and !empty(this->table["tablename"])){
sql = "SELECT count(".this->table["id"].") as count_id FROM `".this->table["tablename"]."` ".(this->table["where"]!=""?" WHERE ".this->table["where"]:"");
}else{
sql = preg_replace("/SELECT(.*?)FROM(.*?)/i", "SELECT count(id) AS count_id FROM\\2", this->sql);
}
arr = this->db->row_query_one(sql);
this->total_records = arr["count_id"];
}
}
/*
* 根據(jù)sql返回查詢數(shù)據(jù)
* 指定sql時(shí),不必指定limit
*/
function get_rows_by_sql(sql){
this->sql = sql." LIMIT ".this->page_size*(this->page-1).", ".this->page_size; //指定的SQL;
return this->db->row_query(this->sql);
}
相關(guān)PHP教程:
- 【PHP Munee】調(diào)整圖片尺寸 + 合并/壓縮CSS JS + 緩存等功能于一身的類
- Detector:檢測(cè)用戶瀏覽器環(huán)境的php類
- PHP Thumb:生成圖片縮略圖的類
- Hybrid Auth:通過微博/社交網(wǎng)站和ID來提供驗(yàn)證功能實(shí)現(xiàn)同步登錄網(wǎng)站功能
- Geocoder:一個(gè)幫助我們建立地理感知應(yīng)用程序的php類庫
- PHPFastCache:強(qiáng)大的開源PHP緩存庫
- PHP Error:解決開發(fā)過程中面臨的PHP錯(cuò)誤信息
- Snoopy:模擬瀏覽器功能的php類庫
- php socket 發(fā)送郵件的庫
- mysql:分頁php類庫
- 簡(jiǎn)單實(shí)用的php mysql數(shù)據(jù)庫連接類
- php生成excel文件的類庫
- 相關(guān)鏈接:
- 教程說明:
PHP教程-解析用PHP操作MySql數(shù)據(jù)庫(3)
。