mysql 类 待更新完善_MySQL

php中文网
发布: 2016-06-01 13:11:38
原创
805人浏览过

<?phpclass Mysql{	//连接句柄	public $con = null;	public function __construct($host,$user,$pwd,$db)	{		$this->connect($host,$user,$pwd,$db);	}	//数据库连接	public function connect($host,$user,$pwd,$db)	{	    $this->con = @mysql_connect($host,$user,$pwd,true);		if(!$this->con)		{			echo '连接失败'.mysql_error();			die();		}		if(!mysql_select_db($db,$this->con))		{			echo '库选择失败'.mysql_error();		}		mysql_query('set names utf8');	}	//查询	Public function query($sql)	{		$rs = mysql_query($sql,$this->con);		if(!$rs)		{			echo 'sql语句错误'.mysql_error();			die();		}		return $rs;	}	//单挑查询	public function find($sql)	{		$rt = mysql_fetch_assoc($this->query($sql));		return $rt;	}	//所有查询	public function findall($sql)	{		$r = $this->query($sql);		$arr = array();		while(($row = mysql_fetch_assoc($r))!=false)		{			$arr[] = $row;		}		return $arr;	}	//查询记录数	public function count($sql)	{		$r = $this->query($sql);		return mysql_num_rows($r);	}	//更新数据	public function update($table,$data,$condition)	{		$sql = 'update '.$table.' set ';		while(list($k,$v) = each($data))		{			$sql .= $k.' = "'.$v.'"'.',';		}		$sql = substr($sql,0,-1);		$sql .=' where 1=1';		while(list($key,$val) = each($condition))		{			$sql .= ' and  '.$key.' = "'.$val.'"';		}		echo $sql;		$this->query($sql);	}	//删除数据	//condition array($key=>$val,.......)	Public function del($table,$condition)	{		//$condition = array('id'=>12,'name'=>'zj');		$sql = 'delete from '.$table.' where 1=1';		while(list($key,$val) = each($condition))		{			$sql .= ' and '.$key.' = "'.$val.'"';		}		$this->query($sql);	}}$db = new Mysql('192.168.0.230','root','fpdev','oa');//$one = print_r($db->find('select * from users'));//$all = print_r($db->findall('select * from users'));//echo $db->count('select * from users');//$db->del('user_bak',array('id'=>1019,'username'=>'katherine'));$db->update('user_bak',array('username'=>'zhangsan'),array('id'=>1020,'username'=>'lq'));
登录后复制


游戏点卡API接口
游戏点卡API接口

点卡API支付接口支持各大游戏类一卡通接口。优势:1、同行业点卡回收支付业务更全;2、同行业点卡回收处理速度更快;3、同行业点卡回收技术更强,支持多卡同时提交;更新内容:1、增加点卡卡密规则文档,发便开发人员根据卡密位数提交前判断;2、增加点卡api接口密钥申请教程,减少在申请过程担误的时间;3、POST传值加密措施更严谨,同行业内存在多年的不足已修复完善;

游戏点卡API接口 0
查看详情 游戏点卡API接口
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门推荐
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号