解析用PHP操作MySql數(shù)據(jù)庫(DB類)_PHP教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:淺析php如何判斷來訪網(wǎng)頁地址php利用系統(tǒng)函數(shù)HTTP_REFERER判斷來訪的網(wǎng)頁地址 如注冊用戶時(shí)必須是來自某網(wǎng)址的 $str=@$_SERVER[’HTTP_REFERER’];//@為除錯功能 if(strstr($str,www.code-123.com))// echo來自www.code-123.com; else echo其它網(wǎng)址;
<?php/*
* mysql數(shù)據(jù)庫 DB類
* @package db
* @author yytcpt(無影)
* @version 2008-03-27
* @copyrigth http://www.d5s.cn/
*/
class db {
var connection_id = "";
var pconnect = 0;
var shutdown_queries = array();
var queries = array();
var query_id = "";
var query_count = 0;
var record_row = array();
var failed = 0;
var halt = "";
var query_log = array();
function connect(db_config){
if (this->pconnect){
this->connection_id = mysql_pconnect(db_config["hostname"], db_config["username"], db_config["password"]);
}else{
this->connection_id = mysql_connect(db_config["hostname"], db_config["username"], db_config["password"]);
}
if ( ! this->connection_id ){
this->halt("Can not connect MySQL Server");
}
if ( ! @mysql_select_db(db_config["database"], this->connection_id) ){
this->halt("Can not connect MySQL Database");
}
if (db_config["charset"]) {
@mysql_unbuffered_query("SET NAMES ’".db_config["charset"]."’");
}
return true;
}
//發(fā)送SQL 查詢,并返回結(jié)果集
function query(query_id, query_type=’mysql_query’){
this->query_id = query_type(query_id, this->connection_id);
this->queries[] = query_id;
if (! this->query_id ) {
this->halt("查詢失敗:\nquery_id");
}
this->query_count++;
this->query_log[] = str;
return this->query_id;
}
//發(fā)送SQL 查詢,并不獲取和緩存結(jié)果的行
function query_unbuffered(sql=""){
return this->query(sql, ’mysql_unbuffered_query’);
}
//從結(jié)果集中取得一行作為關(guān)聯(lián)數(shù)組
function fetch_array(sql = ""){
if (sql == "") sql = this->query_id;
this->record_row = @mysql_fetch_array(sql, MYSQL_ASSOC);
return this->record_row;
}
分享: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í)行時(shí)間
- PHP中獎概率的抽獎算法程序代碼
- apache設(shè)置靜態(tài)文件緩存方法介紹
- php對圖像的各種處理函數(shù)代碼小結(jié)
- PHP 關(guān)于訪問控制的和運(yùn)算符優(yōu)先級介紹
- 關(guān)于PHP語言構(gòu)造器介紹
- php/js獲取客戶端mac地址的實(shí)現(xiàn)代碼
- php5.5新數(shù)組函數(shù)array_column使用
- PHP preg_match的匹配多國語言的技巧
- php 中序列化和json使用介紹
- php采集文章中的圖片獲取替換到本地
- 相關(guān)鏈接:
- 教程說明:
PHP教程-解析用PHP操作MySql數(shù)據(jù)庫(DB類)
。