自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

正確解讀PHP應(yīng)用odbc技巧

開發(fā) 后端
PHP應(yīng)用odbc樂意幫助我們進(jìn)行ACESS數(shù)據(jù)庫的操作。對于新手來說對于這一操作步驟應(yīng)該還不是太清楚。希望通過本文介紹的知識能夠充分掌握這一技巧。

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

PHP應(yīng)用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. 以下錯(cuò)誤信息由ODBC 提供:’. odbc_errormsg();  
  53. exit($message);  
  54. }  
  55. function __destruct()  
  56. {  
  57. odbc_close($this->con);  
  58. }  
  59. }  
  60. ?> 

以上就是PHP應(yīng)用odbc的全部方法步驟,希望對大家有所幫助。

責(zé)任編輯:曹凱 來源: realized.cn
相關(guān)推薦

2009-12-11 16:44:33

PHP冒泡排序

2009-12-09 14:25:21

PHP獲取時(shí)間錯(cuò)誤

2009-12-07 18:57:17

PHP讀取Cookie

2009-12-10 17:54:57

PHP刪除Cookie

2009-12-04 15:43:03

PHP JSON擴(kuò)展

2009-12-10 09:48:26

PHP獲取遠(yuǎn)程圖片

2009-12-08 14:11:03

PHP時(shí)區(qū)修改

2009-12-04 14:09:52

PHP JSON應(yīng)用

2009-12-11 15:35:50

PHP彈出對話框

2009-12-07 14:38:14

PHP foreach

2009-12-08 16:48:25

PHP類phpExce

2009-12-11 17:57:13

PHP應(yīng)用JSON

2009-11-26 09:06:35

PHP遞歸數(shù)組

2009-11-17 11:24:00

PHP應(yīng)用技巧

2009-11-18 18:24:26

PHP模板

2009-12-08 09:51:10

PHP intval函

2009-12-11 10:59:48

PHP函數(shù)extrac

2010-03-03 17:33:52

Python讀取XML

2010-02-26 10:46:12

WCF行為擴(kuò)展

2010-03-01 16:04:31

WCF服務(wù)契約
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號