oci_bind_by_name 在 PHP 中不起作用
任何人都可以指导我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
知道了 !
抱歉打扰你们...我犯了一个愚蠢的错误。
代码行:
$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 !