能给份class的例子吗? class foo { function foo() { echo 'helo'; }}new foo(); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?class DBOperate { var $Host = "localhost"; var $Database = "glasscity"; var $User = "root"; var $Password = ""; var $Link_ID = 0; var $Query_ID = 0; var $Record = array(); var $Row; var $obj;var $Errno = 0; var $Error = ""; var $Auto_free = 0; ## Set this to 1 for automatic mysql_free_result() var $Auto_commit = 0; ## set this to 1 to automatically commit results var $debugmode = 0;function DBOperate(){ $this->connect();}function connect() { if ( 0 == $this->Link_ID ) { $this->Link_ID=mysql_pconnect($this->Host, $this->User, $this->Password); if (!$this->Link_ID) { $this->halt("Link-ID == false, pconnect failed"); } if (!mysql_query(sprintf("use %s",$this->Database),$this->Link_ID)) { $this->halt("cannot use database ".$this->Database); } } } function query($Query_String) { $this->connect(); if ($this->debugmode) printf("Debug: query = %s<br>\n", $Query_String); $this->Query_ID = mysql_query($Query_String,$this->Link_ID); $this->Row = 0; $this->Errno = mysql_errno(); $this->Error = mysql_error(); if (!$this->Query_ID) { $this->halt("Invalid SQL: ".$Query_String); } return $this->Query_ID; } function FetchObject($result='$this->Query_ID'){ $this->obj = mysql_fetch_object($result);}function next_record() { $this->Record = mysql_fetch_array($this->Query_ID); $this->Row += 1; $this->Errno = mysql_errno(); $this->Error = mysql_error(); $stat = is_array($this->Record); if (!$stat && $this->Auto_free) { mysql_free_result($this->Query_ID); $this->Query_ID = 0; } return $this->Record; } function seek($pos) { $status = mysql_data_seek($this->Query_ID, $pos); if ($status) $this->Row = $pos; return; } function metadata($table) { $count = 0; $id = 0; $res = array(); $this->connect(); $id = @mysql_list_fields($this->Database, $table); if ($id < 0) { $this->Errno = mysql_errno(); $this->Error = mysql_error(); $this->halt("Metadata query failed."); } $count = mysql_num_fields($id); for ($i=0; $i<$count; $i++) { $res[$i]["table"] = mysql_field_table ($id, $i); $res[$i]["name"] = mysql_field_name ($id, $i); $res[$i]["type"] = mysql_field_type ($id, $i); $res[$i]["len"] = mysql_field_len ($id, $i); $res[$i]["flags"] = mysql_field_flags ($id, $i); $res["meta"][$res[$i]["name"]] = $i; $res["num_fields"]= $count; } mysql_free_result($id); return $res; } function affected_rows() { return mysql_affected_rows($this->Link_ID); } function num_rows() { return mysql_num_rows($this->Query_ID); } function num_fields() { return mysql_num_fields($this->Query_ID); } function nf() { return $this->num_rows(); } function np() { print $this->num_rows(); } function f($Name) { return $this->Record[$Name]; } function p($Name) { print $this->Record[$Name]; } function halt($msg) { printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg); printf("<b>MySQL Error</b>: %s (%s)<br>\n", $this->Errno, $this->Error); die("Session halted."); } } class SQL extends DBOperate { var $Host = "localhost"; var $Database = ""; var $User = ""; var $Password = ""; function free_result() { return @mysql_free_result($this->Query_ID); } function rollback() { return 1; } function commit() { return 1; } function autocommit($onezero) { return 1; } function insert_id($col="",$tbl="",$qual="") { return mysql_insert_id($this->Query_ID); } } ?> 你可以看看http://www.csdn.net/develop/read_article.asp?id=10934 MySQL 使用php循环执行mysql 长时间执行,是否会执行超时 求php下CRC-16代码,急用!!! 新手请教 PHP 计算两个时间是否差一年 php中文乱码 PHP邮件函数mb_send_mail(),错误警告 mysql 蠕虫复制出错 如何将一个php的数组变成javascript数组 有没有饼图的调查程序(代码)下载 关于apache的问题。 手机支付宝问题 关于blob类型字段的问题,非常棘手! 请提供php开发工具方面的网址我来下载?
class DBOperate {
var $Host = "localhost";
var $Database = "glasscity";
var $User = "root";
var $Password = ""; var $Link_ID = 0;
var $Query_ID = 0;
var $Record = array();
var $Row;
var $obj;var $Errno = 0;
var $Error = ""; var $Auto_free = 0; ## Set this to 1 for automatic mysql_free_result()
var $Auto_commit = 0; ## set this to 1 to automatically commit results var $debugmode = 0;function DBOperate()
{
$this->connect();
}function connect() {
if ( 0 == $this->Link_ID ) {
$this->Link_ID=mysql_pconnect($this->Host, $this->User, $this->Password);
if (!$this->Link_ID) {
$this->halt("Link-ID == false, pconnect failed");
}
if (!mysql_query(sprintf("use %s",$this->Database),$this->Link_ID)) {
$this->halt("cannot use database ".$this->Database);
}
}
} function query($Query_String) {
$this->connect(); if ($this->debugmode)
printf("Debug: query = %s<br>\n", $Query_String); $this->Query_ID = mysql_query($Query_String,$this->Link_ID);
$this->Row = 0;
$this->Errno = mysql_errno();
$this->Error = mysql_error();
if (!$this->Query_ID) {
$this->halt("Invalid SQL: ".$Query_String);
} return $this->Query_ID;
} function FetchObject($result='$this->Query_ID'){
$this->obj = mysql_fetch_object($result);
}function next_record() {
$this->Record = mysql_fetch_array($this->Query_ID);
$this->Row += 1;
$this->Errno = mysql_errno();
$this->Error = mysql_error(); $stat = is_array($this->Record);
if (!$stat && $this->Auto_free) {
mysql_free_result($this->Query_ID);
$this->Query_ID = 0;
}
return $this->Record;
} function seek($pos) {
$status = mysql_data_seek($this->Query_ID, $pos);
if ($status)
$this->Row = $pos;
return;
} function metadata($table) {
$count = 0;
$id = 0;
$res = array(); $this->connect();
$id = @mysql_list_fields($this->Database, $table);
if ($id < 0) {
$this->Errno = mysql_errno();
$this->Error = mysql_error();
$this->halt("Metadata query failed.");
}
$count = mysql_num_fields($id); for ($i=0; $i<$count; $i++) {
$res[$i]["table"] = mysql_field_table ($id, $i);
$res[$i]["name"] = mysql_field_name ($id, $i);
$res[$i]["type"] = mysql_field_type ($id, $i);
$res[$i]["len"] = mysql_field_len ($id, $i);
$res[$i]["flags"] = mysql_field_flags ($id, $i);
$res["meta"][$res[$i]["name"]] = $i;
$res["num_fields"]= $count;
} mysql_free_result($id);
return $res;
} function affected_rows() {
return mysql_affected_rows($this->Link_ID);
} function num_rows() {
return mysql_num_rows($this->Query_ID);
} function num_fields() {
return mysql_num_fields($this->Query_ID);
} function nf() {
return $this->num_rows();
} function np() {
print $this->num_rows();
} function f($Name) {
return $this->Record[$Name];
} function p($Name) {
print $this->Record[$Name];
} function halt($msg) {
printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg);
printf("<b>MySQL Error</b>: %s (%s)<br>\n",
$this->Errno,
$this->Error);
die("Session halted.");
}
} class SQL extends DBOperate {
var $Host = "localhost";
var $Database = "";
var $User = "";
var $Password = ""; function free_result() {
return @mysql_free_result($this->Query_ID);
} function rollback() {
return 1;
} function commit() {
return 1;
} function autocommit($onezero) {
return 1;
} function insert_id($col="",$tbl="",$qual="") {
return mysql_insert_id($this->Query_ID);
}
}
?>
http://www.csdn.net/develop/read_article.asp?id=10934