php mysql 增删改查 封装_php封装一个类能实现mysql数据库的增删改查

按照下面的代码继续的完善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); }}

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值