一个功能还算完整的数据库操作类_PHP教程
程序员文章站
2022-05-15 16:13:26
...
- /*
- * Author 墨龙
- * Time 2010年12月2日 15:50:35
- */
- $db = new mysql($db_host,$db_user,$db_password,$db_table,$db_conn,$pre,$coding);
- class mysql{
- private $db_host;
- private $db_user;
- private $db_password;
- private $db_table;
- private $db_conn; //数据库连接标识;
- private $result; //执行query命令的结果资源标识
- private $sql; //sql执行语句
- private $pre; //数据库表前缀
- private $coding; //数据库编码,GBK,UTF8,gb2312
- function __construct($db_host,$db_user,$db_password,$db_table,$db_conn,$pre,$coding){
- $this->db_host = $db_host;
- $this->db_user = $db_user;
- $this->db_password = $db_password;
- $this->db_table = $db_table;
- $this->db_conn = $db_conn;
- $this->pre = $pre;
- $this->coding = $coding;
- $this->connect();
- }
- function connect(){
- $this->db_conn = @mysql_connect($this->db_host,$this->db_user,$this->db_password) or die($this->show_error("数据库链接错误,请检查数据库链接配置!"));
- if(!mysql_select_db($this->db_table,$this->db_conn)){
- echo "没有找到数据表:".$this->db_table;
- }
- mysql_select_db($this->db_t