脚本宝典收集整理的这篇文章主要介绍了PHP实现的mysql操作类【MySQL与MySQLi方式】,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
本文实例讲述了PHP实现的MysqL操作类。分享给大家供大家参考,具体如下:
PHP;"> ut=$ut; $this->connect(); } //数据库的链接 function connect(){ $link=MysqL_connect($this->host,$this->name,$this->pass) or die ($this->error()); MysqL_select_db($this->table,$link) or die("没该数据库:".$this->table); MysqL_query("SET names '$this->ut'"); } function query($sql,$tyPE = '') { if(!($query = MysqL_query($sql))) $this->show('Say:',$sql); return $query; } function show($message = '',$sql = '') { if(!$sql) echo $message; else echo $message.'
'.$sql; } function affected_rows() { return MysqL_affected_rows(); } function result($query,$row) { return MysqL_result($query,$row); } function num_rows($query) { return @MysqL_num_rows($query); } function num_fields($query) { return MysqL_num_fields($query); } function free_result($query) { return MysqL_free_result($query); } function insert_id() { return MysqL_insert_id(); } function fetch_row($query) { return MysqL_fetch_row($query); } function version() { return MysqL_get_server_info(); } function close() { return MysqL_close(); } //向$table表中插入值 function fn_insert($table,$name,$value){ $this->query("insert into $table ($name) value ($value)"); } //根据$id值删除表$table中的一条记录 function fn_delete($table,$id,$value){ $this->query("delete From $table where $id=$value"); echo "id为". $id." 的记录被成功删除!"; } } $db = new ConnectionMysqL(); $db->fn_insert('test','id,name,sex',"'','hongtenzone','M'"); $db->fn_delete('test','id',1); ?>
以上是脚本宝典为你收集整理的PHP实现的mysql操作类【MySQL与MySQLi方式】全部内容,希望文章能够帮你解决PHP实现的mysql操作类【MySQL与MySQLi方式】所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。