国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務(wù)器之家 - 編程語言 - PHP教程 - Mysql數(shù)據(jù)庫操作類( 1127版,提供源碼下載 )

Mysql數(shù)據(jù)庫操作類( 1127版,提供源碼下載 )

2019-11-12 14:12php教程網(wǎng) PHP教程

Mysql數(shù)據(jù)庫操作類,學(xué)習(xí)php的朋友可以參考下。

Mysql.class.php 下載 

復(fù)制代碼代碼如下:


<?php 
class Mysql { 
private $db_host; //主機地址 
private $db_user; //用戶名 
private $db_pass; //連接密碼 
private $db_name; //名稱 
private $db_charset; //編碼 
private $conn; 
public $debug=false;//調(diào)試開關(guān),默認(rèn)關(guān)閉 
private $query_id; //用于判斷sql語句是否執(zhí)行成功 
private $result; //結(jié)果集 
private $num_rows; //結(jié)果集中行的數(shù)目,僅對select有效 
private $insert_id; //上一步 INSERT 操作產(chǎn)生的 ID 
// 構(gòu)造/析構(gòu)函數(shù) 
function __construct ($db_host,$db_user,$db_pass,$db_name,$db_charset,$conn) { 
$this->db_host = $db_host ; 
$this->db_user = $db_user ; 
$this->db_pass = $db_pass ; 
$this->db_name = $db_name ; 
$this->db_charset = $db_charset ; 
$this->conn = $conn ; 
$this->connect(); 

function __destruct () { 
@mysql_close($this->conn); 

// 連接/選擇數(shù)據(jù)庫 
public function connect () { 
if ($this->conn == 'pconn') { 
@$this->conn = mysql_pconnect($this->db_host,$this->db_user,$this->db_pass); 
} else { 
@$this->conn = mysql_connect($this->db_host,$this->db_user,$this->db_pass); 

if (!$this->conn) { 
$this->show_error('數(shù)據(jù)庫-連接失敗:用戶名或密碼錯誤!'); 

if (!@mysql_select_db($this->db_name,$this->conn)) { 
$this->show_error("數(shù)據(jù)庫-選擇失敗:數(shù)據(jù)庫 $this->db_name 不可用"); 

mysql_query("SET NAMES $this->db_charset"); 
return $this->conn; 

// query方法 
public function query ($sql) { 
if ($this->query_id) $this->free_result(); 
$this->query_id = @mysql_query($sql,$this->conn); 
if (!$this->query_id) $this->show_error("SQL語句 <b>\"$sql\"</b> 執(zhí)行時遇到錯誤"); 
return $this->query_id; 

// 顯示詳細(xì)錯誤信息 
public function show_error ($msg) { 
if($this->debug){ 
$errinfo = mysql_error(); 
echo "錯誤:$msg <br/> 返回:$errinfo<p>"; 
}else{ 
echo '<p>出現(xiàn)錯誤!<p>'; 


// 獲得query執(zhí)行成功與否的信息 
public function get_query_info($info){ 
if ($this->query_id) { 
echo $info; 


// 查詢所有 
public function findall ($table_name) { 
$this->query("select * from $table_name"); 

// mysql_fetch_array 
public function fetch_array () { 
if ($this->query_id) { 
$this->result = mysql_fetch_array($this->query_id); 
return $this->result; 


// ...... 
public function fetch_assoc () { 
if ($this->query_id) { 
$this->result = mysql_fetch_assoc($this->query_id); 
return $this->result; 


public function fetch_row () { 
if ($this->query_id) { 
$this->result = mysql_fetch_row($this->query_id); 
return $this->result; 


public function fetch_object () { 
if ($this->query_id) { 
$this->result = mysql_fetch_object($this->query_id); 
return $this->result; 


// 獲取 num_rows 
public function num_rows () { 
if ($this->query_id) { 
$this->num_rows = mysql_num_rows($this->query_id); 
return $this->num_rows; 


// 獲取 insert_id 
public function insert_id () { 
return $this->insert_id = mysql_insert_id(); 

// 顯示共有多少張表 
public function show_tables () { 
$this->query("show tables"); 
if ($this->query_id) { 
echo "數(shù)據(jù)庫 $this->db_name 共有 ".$this->num_rows($this->query_id)." 張表<br/>"; 
$i = 1; 
while ($row = $this->fetch_array($this->query_id)){ 
echo "$i -- $row[0]<br/>"; 
$i ++; 



// 顯示共有多少個數(shù)據(jù)庫 
public function show_dbs(){ 
$this->query("show databases"); 
if ($this->query_id) { 
echo "共有數(shù)據(jù)庫 ".$this->num_rows($this->query_id)." 個<br/>"; 
$i = 1; 
while ($this->row = $this->fetch_array($this->query_id)){ 
echo "$i -- ".$this->row[Database]."<br />"; 
$i ++; 



// 刪除數(shù)據(jù)庫:返回刪除結(jié)果 
public function drop_db ($db_name='') { 
if ($db_name == '') { 
$db_name = $this->db_name;//默認(rèn)刪除當(dāng)前數(shù)據(jù)庫 
$this->query("DROP DATABASE $db_name"); 
}else { 
$this->query("DROP DATABASE $db_name"); 

if ($this->query_id) { 
return "數(shù)據(jù)庫 $db_name 刪除成功"; 
}else { 
$this->show_error("數(shù)據(jù)庫 $db_name 刪除失敗"); 


// 刪除數(shù)據(jù)表:返回刪除結(jié)果 
public function drop_table ($table_name) { 
$this->query("DROP TABLE $table_name"); 
if ($this->query_id) { 
return "數(shù)據(jù)表 $table_name 刪除成功"; 
}else { 
$this->show_error("數(shù)據(jù)表 $table_name 刪除失敗"); 


// 創(chuàng)建數(shù)據(jù)庫 
public function create_db ($db_name) { 
$this->query("CREATE DATABASE $db_name"); 
if($this->query_id){ 
return "數(shù)據(jù)庫 $db_name 創(chuàng)建成功"; 
}else { 
$this->show_error("數(shù)據(jù)庫 $db_name 創(chuàng)建失敗"); 


// 獲取數(shù)據(jù)庫版本 
public function get_info(){ 
echo mysql_get_server_info(); 

// 釋放內(nèi)存 
public function free_result () { 
if ( @mysql_free_result($this->query_id) ) 
unset ($this->result); 
$this->query_id = 0; 

} // End class 
?> 

 

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 亚洲国产成人av好男人在线观看 | 精品av| 日本久草| 国产精品综合视频 | 亚洲情在线 | 欧美一级久久久 | 亚洲国产精品欧美一二99 | 精品久久久久久久久久久 | 黄色毛片在线视频 | 欧美精品在线一区二区三区 | 久久久性 | 国产一区二区三区在线 | 狠狠操夜夜爱 | 免费黄网站在线观看 | 日韩在线视频免费 | 国产片在线观看 | 欧美性猛交一区二区三区精品 | 亚洲九九九| 日韩精品视频在线播放 | 亚洲精品视频免费观看 | 欧美一区二区在线播放 | 成人欧美一区二区三区在线观看 | 亚洲国产成人av好男人在线观看 | 成年人免费在线看网站 | 中文字幕日本一区二区 | 亚洲精品99 | 国产99精品视频 | 激情五月婷婷基地 | 欧美午夜精品久久久久久浪潮 | 亚洲欧美日韩精品久久亚洲区 | 好吊色欧美一区二区三区四区 | 91麻豆蜜桃一区二区三区 | 黄色a一级| 欧美在线观看一区二区 | 中文字幕日韩一区 | 日日操操| 中文字幕综合在线 | 精品三级 | 最新日韩视频 | 久久久女女女女999久久 | 精品国产黄a∨片高清在线 成人欧美 |