Correct interpretation of PHP application odbc skills_PHP tutorial

WBOY
Release: 2016-07-15 13:33:57
Original
909 people have browsed it

When we apply

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. 以下错误信息由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...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template