天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

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

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;
}
// 顯示詳細錯誤信息
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
?>

php技術(shù)Mysql數(shù)據(jù)庫操作類( 1127版,提供源碼下載 ),轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 国产亚洲999精品AA片在线爽 | 18美女腿打开无遮软件 | 久久热国产在线视频 | 在线观看国产高清免费不卡 | 久草色视频 | 两个人的视频日本在线观看完整 | 果冻传媒2021精品在线观看 | 久久er99热精品一区二区 | 3d无遮挡h肉动漫在线播放 | 亚洲中久无码永久在线 | 色婷婷五月综合中文字幕 | 最近2019年日本中文免费字幕 | 出轨的妻子在线观看 | 久久久久久久免费 | 精品久久久久久无码人妻国产馆 | WINDOWSCHANNEL老太| 国产精品无码视频一区二区 | 国产毛片视频网站 | 久久久久久久久女黄9999 | 紧缚束缚调教丨vk | 成人影片下载网站 | 在线免费观看视频a | 0855午夜福利伦理电影 | 成人午夜剧场 | 肉动漫3D卡通无修在线播放 | 无码中文字幕热热久久 | 榴莲推广APP网站入口下载安装 | 狠狠干.in | RAPPER性骚扰大开黄腔 | 全部老头和老太XXXXX | 草莓视频在线免费观看 | 国内精品久久久久久西瓜色吧 | 精品少妇爆AV无码专区 | 99麻豆精品国产人妻无码 | 成人免费在线观看视频 | 扒开老师大腿猛进AAA片 | 黑人巨大交牲老太 | 午夜男人免费福利视频 | 日本无码人妻精品一区二区视频 | 欧美videqsdesex0| 久见久热 这里只有精品 |