日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php定义数据表类,phpwind中的数据库操作类

發布時間:2024/9/27 php 78 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php定义数据表类,phpwind中的数据库操作类 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

phpwind中的數據庫操作類

2021-01-22 20:12:15141

/*來源:phpwind.net*/

ClassDB{

var$query_num=0;

functionDB($dbhost,$dbuser,$dbpw,$dbname,$pconnect=0){

$this->connect($dbhost,$dbuser,$dbpw,$dbname,$pconnect);

}

functionconnect($dbhost,$dbuser,$dbpw,$dbname,$pconnect=0){

$pconnect==0?@mysql_connect($dbhost,$dbuser,$dbpw):@mysql_pconnect($dbhost,$dbuser,$dbpw);

mysql_errno()!=0&&$this->halt("Connect($pconnect)toMySQLfailed");

if($this->server_info()>'4.1'&&$GLOBALS['charset']){

mysql_query("SETNAMES'".$GLOBALS['charset']."'");

}

if($this->server_info()>'5.0'){

mysql_query("SETsql_mode=''");

}

if($dbname){

if(!@mysql_select_db($dbname)){

$this->halt('Cannotusedatabase');

}

}

}

functionclose(){

returnmysql_close();

}

functionselect_db($dbname){

if(!@mysql_select_db($dbname)){

$this->halt('Cannotusedatabase');

}

}

functionserver_info(){

returnmysql_get_server_info();

}

functionquery($SQL,$method=''){

$GLOBALS['PW']=='pw_'or$SQL=str_replace('pw_',$GLOBALS['PW'],$SQL);

if($method=='U_B'&&function_exists('mysql_unbuffered_query')){

$query=mysql_unbuffered_query($SQL);

}else{

$query=mysql_query($SQL);

}

$this->query_num++;

//echo$SQL.'
'.$this->query_num.'
';

if(!$query)$this->halt('QueryError:'.$SQL);

return$query;

}

functionget_one($SQL){

$query=$this->query($SQL,'U_B');

$rs=&mysql_fetch_array($query,MYSQL_ASSOC);

return$rs;

}

functionpw_update($SQL_1,$SQL_2,$SQL_3){

$rt=$this->get_one($SQL_1);

if($rt){

$this->update($SQL_2);

}else{

$this->update($SQL_3);

}

}

functionupdate($SQL){

$GLOBALS['PW']=='pw_'or$SQL=str_replace('pw_',$GLOBALS['PW'],$SQL);

if($GLOBALS['db_lp']==1){

if(substr($SQL,0,7)=='REPLACE'){

$SQL=substr($SQL,0,7).'LOW_PRIORITY'.substr($SQL,7);

}else{

$SQL=substr($SQL,0,6).'LOW_PRIORITY'.substr($SQL,6);

}

}

if(function_exists('mysql_unbuffered_query')){

$query=mysql_unbuffered_query($SQL);

}else{

$query=mysql_query($SQL);

}

$this->query_num++;

//echo$SQL.'
'.$this->query_num.'
';

if(!$query)$this->halt('UpdateError:'.$SQL);

return$query;

}

functionfetch_array($query,$result_type=MYSQL_ASSOC){

returnmysql_fetch_array($query,$result_type);

}

functionaffected_rows(){

returnmysql_affected_rows();

}

functionnum_rows($query){

$rows=mysql_num_rows($query);

return$rows;

}

functionfree_result($query){

returnmysql_free_result($query);

}

functioninsert_id(){

$id=mysql_insert_id();

return$id;

}

functionhalt($msg=''){

require_once(R_P.'require/db_mysql_error.php');

newDB_ERROR($msg);

}

}

?>

點擊這里復制本文地址

以上內容由聚米學院網友整理呈現,如對侵犯您的權益,請聯系郵箱:fzsbm@qq.com

總結

以上是生活随笔為你收集整理的php定义数据表类,phpwind中的数据库操作类的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。