• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

php封装mysql操作类

php 搞代码 3年前 (2022-01-23) 13次浏览 已收录 0个评论
<?php   class mysql{     private $host;     private $name;     private $pass;     private $table;     private $ut;     function __construct($host,$name,$pass,$table,$ut){     	$this->host=$host;     	$this->name=$name;     	$this->pass=$pass;     	$this->table=$table;     	$@本文来源gaodaimacom搞#代%码@网-搞代gaodaima码this->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(); } //============== function fn_insert($table,$name,$value){ $this->query("insert into $table ($name) value ($value)"); } } $db = new mysql('localhost','root','','data',"GBK");?>

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:php封装mysql操作类
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址