当前位置:Gxlcms > PHP教程 > 一个功能还算完整的数据库操作类_PHP教程

一个功能还算完整的数据库操作类_PHP教程

时间:2021-07-01 10:21:17 帮助过:22人阅读

  1. /*
  2. * Author 墨龙
  3. * Time 2010年12月2日 15:50:35
  4. */
  5. $db = new mysql($db_host,$db_user,$db_password,$db_table,$db_conn,$pre,$coding);
  6. class mysql{
  7. private $db_host;
  8. private $db_user;
  9. private $db_password;
  10. private $db_table;
  11. private $db_conn; //数据库连接标识;
  12. private $result; //执行query命令的结果资源标识
  13. private $sql; //sql执行语句
  14. private $pre; //数据库表前缀
  15. private $coding; //数据库编码,GBK,UTF8,gb2312
  16. function __construct($db_host,$db_user,$db_password,$db_table,$db_conn,$pre,$coding){
  17. $this->db_host = $db_host;
  18. $this->db_user = $db_user;
  19. $this->db_password = $db_password;
  20. $this->db_table = $db_table;
  21. $this->db_conn = $db_conn;
  22. $this->pre = $pre;
  23. $this->coding = $coding;
  24. $this->connect();
  25. }
  26. function connect(){
  27. $this->db_conn = @mysql_connect($this->db_host,$this->db_user,$this->db_password) or die($this->show_error("数据库链接错误,请检查数据库链接配置!"));
  28. if(!mysql_select_db($this->db_table,$this->db_conn)){
  29. echo "没有找到数据表:".$this->db_table;
  30. }
  31. mysql_select_db($this->db_t

    www.bkjia.comtruehttp://www.bkjia.com/PHPjc/486033.htmlTechArticle?php /* *Author墨龙 *Time2010年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...

人气教程排行