按照下面的代码继续的完善publicfunctionmysql_connect(){if($this->links=@mysql_connect($this->host,$this->user,$this->pwd)){if(@mysql_select_db($this->dbName,$this->links))...
按照下面的代码继续的完善
public function mysql_connect(){ if($this->links=@mysql_connect($this->host,$this->user,$this->pwd)){ if(@mysql_select_db($this->dbName,$this->links)){ $this->getCode(); }else{ $this->getMysqlError(); } }else{ $this->getMysqlError(); } } public function getMysqlError(){ echo "连接错误信息是".mysql_error(); echo "
数据库错误信息是".mysql_errno(); } public function getCode(){ if(!empty($code)){ $this->code = $code; } mysql_query("set names".$this->code); } /* select() $can :结果集 */ public function select($res = null){ if(is_resource($res) && !is_null($res)){ $this->res = $res; } $data =array(); while($list=@mysql_fetch_assoc($this->res)){ $data[]=$list; } print_r($data); return $data; } /* find() $can :结果集 */ public function find($res = null){ if(is_resource($res) && !is_null($res)){ $this->res = $res; } return @mysql_fetch_assoc($this->res); }//增删改¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥ //析构函数 public function __destruct(){ mysql_close($this->links); }}
展开