如何使用 php 从 Oracle 返回 Json 格式?我做了这个并用萤火虫调试,没有错误,它没有返回任何东西......但它打印完成!
<?php
$user = "username";
$pass = "password";
$host = "myhost/myservicename";
$conn = oci_connect($user, $pass, $host);
$sql = oci_parse($conn, "SELECT * FROM emp WHERE rownum <100");
oci_execute($sql);
$rows = array();
while($r = oci_fetch_assoc($sql)) {
$rows[] = $r;
}
$locations =(json_encode($rows));
echo 'done!';
?>