询:
$stid = oci_parse($c, 'select * from locations'); oci_execute($stid, OCI_DEFAULT);
oci_fetch_all($stid, $res); 确保在必要时使用双引号:
$stid = oci_parse($c, "select * from locations where city = 'Sydney'"); oci8 包含一些 fetch 函数,PHP oci8 参考手册对其进行了详细说明。 oci_fetch_all():一次性获取所有结果
oci_fetch_array():以您选择的数组形式获取下一行 oci_fetch_assoc():以关联数组的形式获取下一行 oci_fetch_object():以对象形式获取新行
oci_fetch_row():以整数索引的数组形式获取下一行
oci_fetch():与 oci_result()(返回给定字段的结果)一起使用 需要重复调用获取单个行的函数:
$stid = oci_parse($c, "select city from locations"); oci_execute($stid, OCI_DEFAULT); while ($res = oci_fetch_row($stid)) { echo $res[0] ." \n";
}
某些函数包含可更改其行为的可选参数,例如,oci_fetch_array() 提供了一些选项,用于指定是以关联数组形式还是以数字索引数组形式(或同时以关联数组和数字索引数组形式)返回结果。关联数组使用大写列名命名。