解析用PHP操作MySql數(shù)據(jù)庫(DB類)(4)_PHP教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:淺析php如何判斷來訪網(wǎng)頁地址php利用系統(tǒng)函數(shù)HTTP_REFERER判斷來訪的網(wǎng)頁地址 如注冊用戶時必須是來自某網(wǎng)址的 $str=@$_SERVER[’HTTP_REFERER’];//@為除錯功能 if(strstr($str,www.code-123.com))// echo來自www.code-123.com; else echo其它網(wǎng)址;
/* 根據(jù)條件查詢,返回所有記錄
* tbname 表名, where 查詢條件, limit 返回記錄, fields 返回字段
*/
function row_select(tbname, where="", limit=0, fields="*", orderby="id", sort="DESC"){
sql = this->sql_select(tbname, where, limit, fields, orderby, sort);
return this->row_query(sql);
}
//詳細(xì)顯示一條記錄
function row_select_one(tbname, where, fields="*", orderby="id"){
sql = this->sql_select(tbname, where, 1, fields, orderby);
return this->row_query_one(sql);
}
function row_query(sql){
rs = this->query(sql);
rs_num = this->num_rows(rs);
rows = array();
for(i=0; i<rs_num; i++){
rows[] = this->fetch_array(rs);
}
this->free_result(rs);
return rows;
}
function row_query_one(sql){
rs = this->query(sql);
row = this->fetch_array(rs);
this->free_result(rs);
return row;
}
//計數(shù)統(tǒng)計
function row_count(tbname, where=""){
sql = "SELECT count(id) as row_sum FROM `".tbname."` ".(where?" WHERE ".where:"");
row = this->row_query_one(sql);
return row["row_sum"];
}
}
?>
很久沒有發(fā)帖了,把我常用的一些php類文件分享出來。
如果您加了新功能,或者是有改進(jìn),請與大家一起分享。
<?php
db_config["hostname"] = "127.0.0.1"; //服務(wù)器地址
db_config["username"] = "root"; //數(shù)據(jù)庫用戶名
db_config["password"] = "root"; //數(shù)據(jù)庫密碼
db_config["database"] = "wap_blueidea_com"; //數(shù)據(jù)庫名稱
db_config["charset"] = "utf8";
include(’db.php’);
db = new db();
db->connect(db_config);
//例:查詢表 table_name 中 cid=1的所有記錄。
row = db->row_select(’table_name’, ’cid=1’);
?>
分享:php教程之語言中switch的用法介紹?php $czc=reg; switch($czc){ case’reg’://注冊 echo注冊的代碼; break;//如果注釋掉此句,將執(zhí)行下在的代碼,否則終止 case’logout’://退出 echo退出的代碼; break; default://此代碼除了reg,logout外其它的都是執(zhí)行以下面的代碼 include’user/in
相關(guān)PHP教程:
- PHPNOW安裝Memcached擴(kuò)展方法詳解
- php記錄頁面代碼執(zhí)行時間
- PHP中獎概率的抽獎算法程序代碼
- apache設(shè)置靜態(tài)文件緩存方法介紹
- php對圖像的各種處理函數(shù)代碼小結(jié)
- PHP 關(guān)于訪問控制的和運(yùn)算符優(yōu)先級介紹
- 關(guān)于PHP語言構(gòu)造器介紹
- php/js獲取客戶端mac地址的實現(xiàn)代碼
- php5.5新數(shù)組函數(shù)array_column使用
- PHP preg_match的匹配多國語言的技巧
- php 中序列化和json使用介紹
- php采集文章中的圖片獲取替換到本地
- 相關(guān)鏈接:
- 教程說明:
PHP教程-解析用PHP操作MySql數(shù)據(jù)庫(DB類)(4)
。