oci_bind_by_name 在 PHP 中不起作用

发布于 2024-10-16 12:42:26 字数 809 浏览 5 评论 0原文

任何人都可以指导我使用 oci_bind_by_name。我已经编写了这段代码:

$connection = initDB();
$validation_query = "SELECT * from admin where admin_id= :uid and password= :pwd";
$s = oci_parse($connection, $validation_query);
oci_bind_by_name($s, ':uid', $id);
oci_bind_by_name($s, ':pwd', $pass);
$res=oci_execute($s, OCI_DEFAULT);
$result_row = oci_fetch_array($s, OCI_ASSOC);

但是只需对代码进行轻微修改并动态生成查询,它就可以开始工作。

$connection = initDB();    
$validation_query = "SELECT * from admin where admin_id= '".$id."' and password= '".$pass."'";
$s = oci_parse($connection, $validation_query);
//oci_bind_by_name($s, ':uid', $id);
//oci_bind_by_name($s, ':pwd', $pass);
$res=oci_execute($s, OCI_DEFAULT);
$result_row = oci_fetch_array($s, OCI_BOTH);

我对此一无所知,并且已经搜索过论坛和互联网。请帮助我。

Can anyone guide me on using oci_bind_by_name. I have written this piece of code:

$connection = initDB();
$validation_query = "SELECT * from admin where admin_id= :uid and password= :pwd";
$s = oci_parse($connection, $validation_query);
oci_bind_by_name($s, ':uid', $id);
oci_bind_by_name($s, ':pwd', $pass);
$res=oci_execute($s, OCI_DEFAULT);
$result_row = oci_fetch_array($s, OCI_ASSOC);

But with slight modification to Code and generating the query on the fly, it starts working.

$connection = initDB();    
$validation_query = "SELECT * from admin where admin_id= '".$id."' and password= '".$pass."'";
$s = oci_parse($connection, $validation_query);
//oci_bind_by_name($s, ':uid', $id);
//oci_bind_by_name($s, ':pwd', $pass);
$res=oci_execute($s, OCI_DEFAULT);
$result_row = oci_fetch_array($s, OCI_BOTH);

I have no idea on this and have already searched forums and internet. Kindly help me out.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拔了角的鹿 2024-10-23 12:42:26

知道了 !
抱歉打扰你们...我犯了一个愚蠢的错误。

代码行:$result_row = oci_fetch_array($s, OCI_BOTH)在这两个代码中都被执行。但在第二种情况下 $result_row[0] 返回值,而 $result_row[0] 在第一种情况下失败。

这又是因为我使用了不同的获取数据模式。第一种情况为 OCI_ASSOC,第二种情况为 OCI_BOTH。

所以最后当我写 $result_row['ID'] 时,我得到了想要的结果。

干杯!

GOT IT !
Sorry to bother you guys... I made a silly mistake.

The line of code: $result_row = oci_fetch_array($s, OCI_BOTH)was being executed in both the codes. But in Second scenario $result_row[0] returned values where as $result_row[0] fails in 1st scenario.

This is again because I was using different MODES of fetching data. OCI_ASSOC in first case and OCI_BOTH in second case.

So finally when I wrote $result_row['ID'], I got the desired results.

Cheers !

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文