The correct interpretation of PHP application ODBC tips _php Tutorial

Source: Internet
Author: User
When we are applying

PHP application ODBC specific code:

  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. The following error message is provided by ODBC: '. Odbc_errormsg ();
  53. Exit ($message);
  54. }
  55. function __destruct ()
  56. {
  57. odbc_close ($this->con);
  58. }
  59. }
  60. ?>

The above is the PHP application of all the methods of ODBC, we hope to help.


http://www.bkjia.com/PHPjc/446028.html www.bkjia.com true http://www.bkjia.com/PHPjc/446028.html techarticle when we apply the ODBC specific code in PHP application: classodbc_db {var$ con = null; var$ resource = null; Function__construct () {} Functionconne CT ($ DSN =, $ user =,$ passwd =, $ cu ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.