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

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

Mysql.class.php 下載
復(fù)制代碼 代碼如下:
<?php
class Mysql {
private $db_host; //主機(jī)地址
private $db_user; //用戶名
private $db_pass; //連接密碼
private $db_name; //名稱
private $db_charset; //編碼
private $conn;
public $debug=false;//調(diào)試開(kāi)關(guān),默認(rèn)關(guān)閉
private $query_id; //用于判斷sql語(yǔ)句是否執(zhí)行成功
private $result; //結(jié)果集
private $num_rows; //結(jié)果集中行的數(shù)目,僅對(duì)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ù)庫(kù)
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ù)庫(kù)-連接失敗:用戶名或密碼錯(cuò)誤!');
}
if (!@mysql_select_db($this->db_name,$this->conn)) {
$this->show_error("數(shù)據(jù)庫(kù)-選擇失敗:數(shù)據(jù)庫(kù) $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語(yǔ)句 <b>/"$sql/"</b> 執(zhí)行時(shí)遇到錯(cuò)誤");
return $this->query_id;
}
// 顯示詳細(xì)錯(cuò)誤信息
public function show_error ($msg) {
if($this->debug){
$errinfo = mysql_error();
echo "錯(cuò)誤:$msg <br/> 返回:$errinfo<p>";
}else{
echo '<p>出現(xiàn)錯(cuò)誤!<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();
}
// 顯示共有多少?gòu)埍?
public function show_tables () {
$this->query("show tables");
if ($this->query_id) {
echo "數(shù)據(jù)庫(kù) $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 ++;
}
}
}
// 顯示共有多少個(gè)數(shù)據(jù)庫(kù)
public function show_dbs(){
$this->query("show databases");
if ($this->query_id) {
echo "共有數(shù)據(jù)庫(kù) ".$this->num_rows($this->query_id)." 個(gè)<br/>";
$i = 1;
while ($this->row = $this->fetch_array($this->query_id)){
echo "$i -- ".$this->row[Database]."<br />";
$i ++;
}
}
}
// 刪除數(shù)據(jù)庫(kù):返回刪除結(jié)果
public function drop_db ($db_name='') {
if ($db_name == '') {
$db_name = $this->db_name;//默認(rèn)刪除當(dāng)前數(shù)據(jù)庫(kù)
$this->query("DROP DATABASE $db_name");
}else {
$this->query("DROP DATABASE $db_name");
}
if ($this->query_id) {
return "數(shù)據(jù)庫(kù) $db_name 刪除成功";
}else {
$this->show_error("數(shù)據(jù)庫(kù) $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ù)庫(kù)
public function create_db ($db_name) {
$this->query("CREATE DATABASE $db_name");
if($this->query_id){
return "數(shù)據(jù)庫(kù) $db_name 創(chuàng)建成功";
}else {
$this->show_error("數(shù)據(jù)庫(kù) $db_name 創(chuàng)建失敗");
}
}
// 獲取數(shù)據(jù)庫(kù)版本
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ù)庫(kù)操作類( 1127版,提供源碼下載 ),轉(zhuǎn)載需保留來(lái)源!

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

主站蜘蛛池模板: 俄罗斯少女人体 | 姑娘视频日本在线播放 | 饥渴的护士自慰被发现 | 亚洲VA天堂VA欧美VA在线 | 香蕉人人超人人超碰超国产 | 国产福利视频一区二区 | 亚洲乱亚洲乱妇在线观看 | 中文字幕本庄优花喂奶 | 青娱乐极品视觉盛宴av | 国产婷婷色综合AV蜜臀AV | 亚洲综合日韩中文字幕v在线 | 无人区日本电影在线观看高清 | 国产国产成人人免费影院 | 国产A级毛片久久久久久久 国产a级黄色毛片 | 俄罗斯美女破处 | 久久婷婷五月免费综合色啪 | 蜜臀AV99无码精品国产专区 | 日本无吗高清 | 湖南张丽大战黑人hd视频 | 2020国产成人精品视频人 | 色综合 亚洲 自拍 欧洲 | 国产精品视频国产永久视频 | 久久99r66热这里只有精品 | www国产av偷拍在线播放 | 夜夜穞狠狠穞 | 亚洲欧美日韩国产手机在线 | 亚洲乱色视频在线观看 | 久久精品国产99欧美精品亚洲 | 男女边吃奶边做边爱视频 | 国产在线播放精品视频 | 色婷婷AV99XX | 大中国免费视频大全在线观看 | china野外18:19 | china中国gay偷拍| 久久婷婷色香五月综合激情 | 色婷婷国产精品视频一区二区 | 无限资源好看片2019免费观看 | 97超碰在线视频 免费 | 亚洲欧美日韩另类精品一区二区三区 | gratis videos欧美最新 | 高H各种PLAY全肉NP |