How to fetch single row from Oracle in PHP?

删除回忆录丶 提交于 2019-12-06 03:51:19

Basically, you just have to remove the while loop.

Here's a rewrite of your code applying that change (+ you use too many parenthesis, decreasing your code readability + you should use SQL binding to avoid injection):

$query_ora_update = "UPDATE app.ITEM_INFO SET ITEM_FLAG= 'Y', LAST_UPDATE_DATE = sysdate WHERE ITEM_FLAG = 'N'";
$parse_result = oci_parse($conn, $query_ora_update);
$result = oci_execute($parse_result);

oci_commit($conn);
oci_close($conn);
Oswaldo Acauan

To fetch a single row in Oracle, add in your where clause the following condition:

ROWNUM = 1

Unfortunately could not understand the rest of your code, did not understand why the "ifs" if you already have the same condition in the where clause of your update.

The Oracle equivalent to mysql_fetch_assoc is oci_fetch_assoc :)

$parsed = ociparse($conn, $sql);
while ($row = oci_fetch_assoc($parsed))
{
    // your logic here
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!