如何使用php从Oracle返回Json格式?我做了这个并用firebug进行了调试,没有任何错误,它没有返回任何内容......但它已经完成了打印!
<?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!';
?>
答案 0 :(得分:2)
响应就是您打印页面的内容。
所以将'done!'
更改为$locations