对于掉入这个陷阱的其他人,这里是该oci_fetch_all
方法将返回的内容的简单摘要。
$s = oci_parse($conn, "
SELECT 1 AS A FROM DUAL
UNION SELECT 2 AS A FROM DUAL
UNION SELECT 3 AS A FROM DUAL
UNION SELECT 4 AS A FROM DUAL
");
oci_execute($s);
echo "records fetched: ". oci_num_rows($s)."\n";
oci_fetch($s);
echo "records fetched: ". oci_num_rows($s)."\n";
oci_fetch($s);
echo "records fetched: ". oci_num_rows($s)."\n";
oci_fetch_all($s, $out);
echo "records fetched: ". oci_num_rows($s)." out count: ". count($out['A']) . "\n";
将输出:
records fetched: 0
records fetched: 1
records fetched: 2
records fetched: 4 out count: 2
增量也是如此oci_num_rows
,每次调用oci_fetch
都会将计数器加一(假设至少还有一条记录要获取),oci_fetch_all
并将获取所有剩余的行并将它们放入$out
缓冲区。