1
Sunyanzi 2014 年 6 月 23 日 via Android
|
3
raincious 2014 年 6 月 23 日 via Android
|
4
smblog 2014 年 6 月 23 日
没 SID 就这样配置
$hostname = 'localhost'; $username = 'user'; $password = 'pass'; $database = 'db'; $datastr = "(description=(address=(protocol=tcp) (host=".$hostname.")(port=1521)) (connect_data=(service_name=".$database.")))"; if(!$link = oci_connect($username,$password,$datastr)) { die('Can not connect to Oracle server'); } $sql = "select * from uset_tabs"; $result = oci_parse($link,$sql); oci_execute($result); $res = oci_fetch_array($result, OCI_ASSOC); print_r($res); |
5
zencoding 2014 年 6 月 23 日
@rmtjp 最佳解决方案 https://github.com/catfan/Medoo 不谢
|
6
zhanglp888 2014 年 7 月 10 日
<?php
$c = oci_connect('用户名', '密码', '地址/sid','UTF8'); if (!$c) { $m = oci_error(); trigger_error('Could not connect to database: '. $m['message'], E_USER_ERROR); } $s = oci_parse($c, "SELECT * FROM employees"); if (!$s) { $m = oci_error($c); trigger_error('Could not parse statement: '. $m['message'], E_USER_ERROR); } $r = oci_execute($s); if (!$r) { $m = oci_error($s); trigger_error('Could not execute statement: '. $m['message'], E_USER_ERROR); } $r = oci_fetch_all($s, $res); if (!$r) { $m = oci_error($s); trigger_error('Could not fetch rows: '. $m['message'], E_USER_ERROR); } echo "<table border='1'>\n"; foreach ($res as $row) { echo "<tr>\n"; foreach ($row as $item) { echo " <td>".($item!==null?htmlentities($item, ENT_QUOTES):" ")."</td>\n"; } echo "</tr>\n"; } echo "</table>\n"; ?> |