解析用PHP操作MySql數(shù)據(jù)庫(kù)(DB類)(3)_PHP教程
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!
推薦:淺析php如何判斷來(lái)訪網(wǎng)頁(yè)地址php利用系統(tǒng)函數(shù)HTTP_REFERER判斷來(lái)訪的網(wǎng)頁(yè)地址 如注冊(cè)用戶時(shí)必須是來(lái)自某網(wǎng)址的 $str=@$_SERVER[’HTTP_REFERER’];//@為除錯(cuò)功能 if(strstr($str,www.code-123.com))// echo來(lái)自www.code-123.com; else echo其它網(wǎng)址;
//錯(cuò)誤提示
function halt(the_error=""){
message = the_error."<br/>\r\n";
message.= this->get_errno() . "<br/>\r\n";
sql = "INSERT INTO `db_error`(pagename, errstr, timer) VALUES(’"._SERVER["PHP_SELF"]."’, ’".addslashes(message)."’, ".time().")";
@mysql_unbuffered_query(sql);
if (DEBUG==true){
echo "<html><head><title>MySQL 數(shù)據(jù)庫(kù)錯(cuò)誤</title>";
echo "<style type=\"text/css\"><!--.error { font: 11px tahoma, verdana, arial, sans-serif, simsun; }--></style></head>\r\n";
echo "<body>\r\n";
echo "<blockquote>\r\n";
echo "<textarea class=\"error\" rows=\"15\" cols=\"100\" wrap=\"on\" >" . htmlspecialchars(message) . "</textarea>\r\n";
echo "</blockquote>\r\n</body></html>";
exit;
}
}
function __destruct(){
this->shutdown_queries = array();
this->close_db();
}
function sql_select(tbname, where="", limit=0, fields="*", orderby="id", sort="DESC"){
sql = "SELECT ".fields." FROM `".tbname."` ".(where?" WHERE ".where:"")." ORDER BY ".orderby." ".sort.(limit ? " limit ".limit:"");
return sql;
}
function sql_insert(tbname, row){
foreach (row as key=>value) {
sqlfield .= key.",";
sqlvalue .= "’".value."’,";
}
return "INSERT INTO `".tbname."`(".substr(sqlfield, 0, -1).") VALUES (".substr(sqlvalue, 0, -1).")";
}
function sql_update(tbname, row, where){
foreach (row as key=>value) {
sqlud .= key."= ’".value."’,";
}
return "UPDATE `".tbname."` SET ".substr(sqlud, 0, -1)." WHERE ".where;
}
function sql_delete(tbname, where){
return "DELETE FROM `".tbname."` WHERE ".where;
}
//新增加一條記錄
function row_insert(tbname, row){
sql = this->sql_insert(tbname, row);
return this->query_unbuffered(sql);
}
//更新指定記錄
function row_update(tbname, row, where){
sql = this->sql_update(tbname, row, where);
return this->query_unbuffered(sql);
}
//刪除滿足條件的記錄
function row_delete(tbname, where){
sql = this->sql_delete(tbname, where);
return this->query_unbuffered(sql);
}
分享:php教程之語(yǔ)言中switch的用法介紹?php $czc=reg; switch($czc){ case’reg’://注冊(cè) echo注冊(cè)的代碼; break;//如果注釋掉此句,將執(zhí)行下在的代碼,否則終止 case’logout’://退出 echo退出的代碼; break; default://此代碼除了reg,logout外其它的都是執(zhí)行以下面的代碼 include’user/in
相關(guān)PHP教程:
- PHPNOW安裝Memcached擴(kuò)展方法詳解
- php記錄頁(yè)面代碼執(zhí)行時(shí)間
- PHP中獎(jiǎng)概率的抽獎(jiǎng)算法程序代碼
- apache設(shè)置靜態(tài)文件緩存方法介紹
- php對(duì)圖像的各種處理函數(shù)代碼小結(jié)
- PHP 關(guān)于訪問(wèn)控制的和運(yùn)算符優(yōu)先級(jí)介紹
- 關(guān)于PHP語(yǔ)言構(gòu)造器介紹
- php/js獲取客戶端mac地址的實(shí)現(xiàn)代碼
- php5.5新數(shù)組函數(shù)array_column使用
- PHP preg_match的匹配多國(guó)語(yǔ)言的技巧
- php 中序列化和json使用介紹
- php采集文章中的圖片獲取替換到本地
- 相關(guān)鏈接:
- 教程說(shuō)明:
PHP教程-解析用PHP操作MySql數(shù)據(jù)庫(kù)(DB類)(3)
。