PHP常用类

2016-1-21 chenhui 随笔

MYSQL:

class SqlHelper {
	
	public $conn;
	public $dbname = "dbname";
	public $username = "root";
	public $password = "0557430568";
	public $host = "localhost";
	
	public function __construct (){
		
		$this->conn = mysql_connect($this->host,$this->username,$this->password);
		if (!$this->conn)
			die("连接失败".mysql_error());
		mysql_select_db($this->dbname,$this->conn);
	}
	
	
	/* 执行一条SQL语句 */
	public function query($sql){
		
		$res = mysql_query($sql,$this->conn) or die(mysql_error()) ;
		return res;
	}
	
	/* 执行一条SQL语句,并返回是否成功的结果 */
	public function query_dml($sql){
		
		$res = mysql_query($sql,$this->conn) ;
		if (!$res){
			
			return 0;
		}else {
				
			if (mysql_affected_rows($this->conn) > 0){
					
				return 1;// 执行成功
			}else {
					
				return 2;// 没有行受到影响
			}
		}
	}		
	
	/* 关闭连接 */
	public function close(){
		
		if (!empty($this->conn))
			mysql_close($this->conn);
	}		
}

==========

分页类

 

=============

略缩图类

 

 

===============

验证码类

 

 

==================

JSON 类

 

 

======================

XML 类

 

 

=================

文件上传类

 

 

 

===============

文件操作类

 

 

 

 

 

发表评论:

Copyright ©2015-2016 freehui All rights reserved