[PHP] php sql类 →→→→→进入此内容的聊天室

来自 , 2020-01-02, 写在 PHP, 查看 136 次.
URL http://www.code666.cn/view/6fe13163
  1. <? class SQL {
  2. var $Driver;  
  3. //实际操作的数据库驱动子类  
  4. var $connection;  
  5. //共用的数据库连接变量  
  6. function DriverRegister($d) {  
  7. if($d!="") { $include_path = ini_get("include_path");  
  8. $DriverFile = $include_path."/".$d.".php";  
  9. //驱动的存放路径必须在PHP.ini文件中设定的INCLUDE_PATH下  
  10. if( file_exists( $DriverFile)) //查找驱动是否存在  
  11. {  
  12. include($DriverFile); $this->Driver = new $d();  
  13. // 根据驱动名称生成相应的数据库驱动类  
  14. return true;  
  15. }  
  16. }  
  17. return false;  
  18. //注册驱动失败  
  19. }  
  20. function Connect($host,$user,$passwd,$database)  
  21. //连接数据库的函数  
  22. { $this->Driver->host=$host;  
  23. $this->Driver->user=$user;  
  24. $this->Driver->passwd=$passwd;  
  25. $this->Driver->database=$database;  
  26. $this->connection = $this->Driver->Connect();  
  27. }  
  28. function Close()  
  29. //关闭数据库函数  
  30. {  
  31. $this->Driver->close($this->connection);  
  32. }  
  33. function Query($queryStr)  
  34. //数据库字符串查询函数 {  
  35. return $this->Driver->query($queryStr,$this->connection);  
  36. }  
  37. function getRows($res)  
  38. //查找行  
  39. {  
  40. return $this->Driver->getRows($res);  
  41. }  
  42. function getRowsNum($res)  
  43. //取得行号  
  44. {  
  45. return $this->Driver-> getRowsNum ($res);  
  46. }  
  47. }  
  48. ? >

回复 "php sql类"

这儿你可以回复上面这条便签

captcha