当前位置:Gxlcms > PHP教程 > 正确解读PHP应用odbc技巧_PHP教程

正确解读PHP应用odbc技巧_PHP教程

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

当我们在应用

PHP应用odbc具体代码:

  1. class odbc_db
  2. {
  3. var $con = null;
  4. var $resource = null;
  5. function __construct()
  6. {
  7. }
  8. function connect($dsn = ” ,
    $
    user = ” , $passwd = ” ,
    $
    cursor_type = 0)
  9. {
  10. !$dsn && $this->debug(’dsn not provided!’);
  11. $this->con = odbc_connect($dsn ,$user
    , $passwd ,$cursor_type);
  12. !$this->con && $this->debug(’conncet failed!’);
  13. return $this->con;
  14. }
  15. function query($sql = ”)
  16. {
  17. $this->resource = odbc_exec($this->con , $sql);
  18. !$this->resource && $this->debug
    (’query failed!’);
  19. return $this->resource;
  20. }
  21. function fetch_array($resource = ”)
  22. {
  23. !$resource && $resource = $this->resource;
  24. return odbc_fetch_array($resource);
  25. }
  26. function query_first($sql = ”)
  27. {
  28. $resource = $this->query($sql);
  29. return odbc_fetch_array($resource);
  30. }
  31. function fetch_all($resource = ”)
  32. {
  33. !$resource && $resource = $this->resource;
  34. $results = array();
  35. while(false !== ($row = @odbc_fetch_
    array($resource)))
  36. {
  37. $results[] = $row;
  38. }
  39. return $results;
  40. }
  41. function num_rows()
  42. {
  43. return odbc_num_rows($this->con);
  44. }
  45. function affected_rows()
  46. {
  47. return odbc_num_rows($this->con);
  48. }
  49. function debug($message = ”)
  50. {
  51. $message .= ‘
  52. 以下错误信息由ODBC 提供:’. odbc_errormsg();
  53. exit($message);
  54. }
  55. function __destruct()
  56. {
  57. odbc_close($this->con);
  58. }
  59. }
  60. ?>

以上就是PHP应用odbc的全部方法步骤,希望对大家有所帮助。


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/446028.htmlTechArticle当我们在应用 PHP应用odbc具体代码: classodbc_db { var$ con = null ; var$ resource = null ; function__construct() { } functionconnect($ dsn =, $ user =,$ passwd =, $ cu...

人气教程排行