<? |
class MysqlConn { |
private $conn ; |
private $my_db ; |
private $result ; |
|
public function __construct() { |
require_once ( "db_config.php" ); |
$this ->conn = mysql_pconnect( $db_server , $db_user , $db_pwd ); |
$this ->my_db = mysql_select_db( $db_name , $this ->conn); //选择数据库 |
|
} |
|
public function query( $sql ){ |
$this ->result = mysql_query( $sql , $this ->conn); // 执行查询语句 |
return $this ->result; |
} |
|
public function next(){ |
return $row = mysql_fetch_array( $this ->result); |
|
} |
|
public function close(){ |
mysql_free_result( $this ->result); |
} |
//使用转义字符,保证系统安全. |
public function escapeString( $str ){ |
return mysql_escape_string( $str ); |
} |
} |
?> |