<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

 

修改/etc/ld.so.conf文件

#vim /etc/ld.so.conf

追加以下内容

/usr/lib/oracle/10.2.0.4/client/lib/

#ldconfig(执行命令)

一、下载OCI8组件

#tar zxvf oci8-1.4.1.tgz

二、编辑OCI8模块

#cd oci8-1.4.1

#phpize(执行命令)

#./configure --with-oci8=instantclient,/usr/lib/oracle/10.2.0.4/client/lib/

#make install

成功后系统会提示你:oci8.so已经成功放入/usr/lib/php/modules/目录中

三、修改php.ini文件

#vim /etc/php.ini

追加以下内容

extension=oci8.so

四、重启Apache服务

service httpd restart

五、使用phpinfo()函数查看

1

六、编辑php代码连接测试oracle数据库

1.  <?php 

2.   

3.  $conn = oci_connect('scott', 'oracle', '192.168.12.133/orcl');  

4.   

5.  if (!$conn) {  

6.   

7.  $e = oci_error();  

8.   

9.  print htmlentities($e['message']);  

10.  

11. exit;  

12.  

13. }  

14.  

15. $query = 'select ename,sal from scott.emp';  

16.  

17. $stid = oci_parse($conn, $query);  

18. if (!$stid) {  

19.  

20. $e = oci_error($conn);  

21.  

22. print htmlentities($e['message']);  

23.  

24. exit;  

25.  

26. }  

27.  

28. $r = oci_execute($stid, OCI_DEFAULT);  

29. if(!$r) {  

30.  

31. $e = oci_error($stid);  

32.  

33. echo htmlentities($e['message']);  

34.  

35. exit;  

36.  

37. }  

38.  

39. print '<table border="1">';  

40.  

41. while($row = oci_fetch_array($stid, OCI_RETURN_NULLS)) {  

42.  

43. print '<tr>';  

44.  

45. foreach($row as $item) {  

46.  

47. print '<td>'.($item?htmlentities($item):' ').'</td>';  

48.  

49. }  

50.  

51. print '</tr>';  

52.  

53. }  

54.  

55. print '</table>';  

56.  

57. oci_close($conn);  

58.  

59. ?> 

 本文转自:ocp认证http://www.cuug.com/