gpt4 book ai didi

php和oracle OCI查询

转载 作者:可可西里 更新时间:2023-11-01 01:15:33 25 4
gpt4 key购买 nike

这段代码有问题

$stmt = oci_parse($db, $sql);
$isQueryOk = oci_execute($stmt);
if ($isQueryOk) {
while (($row = oci_fetch_assoc($stmt)) != false) {
array_push($results, $row);
}
echo json_encode($results);
} else {
$msg = "Error FETCHING ALL [$sql] on " . mb_strtoupper($dbTable) . "!";
}

问题是如果 oci_fetch_assoc($stmt) 返回 20000 行,while (($row = oci_fetch_assoc($stmt)) != false) {
array_push($results, $row);
需要很多时间。有没有一种方法可以在没有 WHILE 循环的情况下返回 echo json_encode($results);

提前致谢。

最佳答案

或者尝试使用另一种方式来推送您的数组。 “注意:如果您使用 array_push() 向数组添加一个元素,最好使用 $array[] =,因为这样就没有调用函数的开销。” http://php.net/manual/en/function.array-push.php

$results[] = $row;

关于php和oracle OCI查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40107363/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com