你好,游客 登录 注册 搜索
背景:
阅读新闻

PHP客户端连接Oracle数据库

[日期:2013-03-08] 来源:51cto  作者:laoxu [字体:大 中 小]

9.编辑php代码连接测试Oracle数据库

  1. <?php
  2. $conn = oci_connect('scott', 'oracle', '192.168.12.133/orcl');
  3. if (!$conn) {
  4. $e = oci_error();
  5. print htmlentities($e['message']);
  6. exit;
  7. }
  8. $query = 'select ename,sal from scott.emp';
  9. $stid = oci_parse($conn, $query);
  10. if (!$stid) {
  11. $e = oci_error($conn);
  12. print htmlentities($e['message']);
  13. exit;
  14. }
  15. $r = oci_execute($stid, OCI_DEFAULT);
  16. if(!$r) {
  17. $e = oci_error($stid);
  18. echo htmlentities($e['message']);
  19. exit;
  20. }
  21. print '<tableborder="1">';
  22. while($row = oci_fetch_array($stid, OCI_RETURN_NULLS)) {
  23. print '<tr>';
  24. foreach($row as $item) {
  25. print '<td>'.($item?htmlentities($item):' ').'</td>';
  26. }
  27. print '</tr>';
  28. }
  29. print '</table>';
  30. oci_close($conn);
  31. ?>

最后通过浏览器浏览页面

更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

linux
相关资讯       Oracle数据库连接 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款