《我的人生还是代码》
class ConnDB{ var $dbtype; var $host; var $user; var $pwd; var $dbname; var $conn; function ConnDB($dbtype,$host,$user,$pwd,$dbname){ $this->dbtype=$dbtype; $this->host=$host; $this->user=$user; $this->pwd=$pwd; $this->dbname=$dbname; } function GetConnld(){ $this->conn=mysql_connect($this->host,$this->user,$this->pwd) or die("数据库服务器连接错误".mysql_error())); mysql_select_db($this->dbname,$this->conn)or die("数据库访问错误".mysql_error()); mysql_query("set names gb2312"); return $this->conn; } function CloseConnld(){ $this->conn->Disconnect(); } } |