PHP如何應用odbc技巧

PHP如何應用odbc技巧,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。

成都創(chuàng)新互聯(lián)專注于企業(yè)全網(wǎng)營銷推廣、網(wǎng)站重做改版、融安網(wǎng)站定制設計、自適應品牌網(wǎng)站建設、HTML5建站、商城網(wǎng)站建設、集團公司官網(wǎng)建設、成都外貿網(wǎng)站建設、高端網(wǎng)站制作、響應式網(wǎng)頁設計等建站業(yè)務,價格優(yōu)惠性價比高,為融安等各大城市提供網(wǎng)站開發(fā)制作服務。

當我們在應用PHP語言對ACCESS數(shù)據(jù)庫操作時,通常都會用到PHP中的odbc。下面我們就來具體認識一下PHP應用odbc是如何操作ACCESS數(shù)據(jù)庫的。

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. ?> 

看完上述內容是否對您有幫助呢?如果還想對相關知識有進一步的了解或閱讀更多相關文章,請關注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對創(chuàng)新互聯(lián)的支持。

文章題目:PHP如何應用odbc技巧
網(wǎng)站URL:http://muchs.cn/article22/jpgejc.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、響應式網(wǎng)站、商城網(wǎng)站、云服務器、網(wǎng)站設計公司、服務器托管

廣告

聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

外貿網(wǎng)站制作