简体   繁体   English

oci_bind_by_name在PHP中不起作用

[英]oci_bind_by_name not working in PHP

Can anyone guide me on using oci_bind_by_name. 谁能指导我使用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. 但是,只要对Code稍加修改并即时生成查询,它就会开始工作。

$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. 请帮我。

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. 代码行: $result_row = oci_fetch_array($s, OCI_BOTH)正在两个代码中执行。 But in Second scenario $result_row[0] returned values where as $result_row[0] fails in 1st scenario. 但是在第二种情况下, $result_row[0]返回的值在第一种情况下为$result_row[0]失败。

This is again because I was using different MODES of fetching data. 再次是因为我使用了不同的模式来获取数据。 OCI_ASSOC in first case and OCI_BOTH in second case. 第一种情况为OCI_ASSOC,第二种情况为OCI_BOTH。

So finally when I wrote $result_row['ID'] , I got the desired results. 所以最后,当我写$result_row['ID'] ,我得到了想要的结果。

Cheers ! 干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM