-1
我正在嘗試計算包含特定數據的行數。在這種情況下,我使用綁定變量來執行任務。oci_execute返回計數錯誤值(*)
<?php
$aid = 1;
$shortName = "TroubleMgt";
$description = "Trouble Management";
$type = "TroubleMgt";
# Lets assume I have already successfully connected to my database
$stid = oci_parse($cnx,"select count(*) TOTAL from aradmin.activities where aid = :aid and shortName = :shortName and description = :description and type = :type");
oci_bind_by_name($stid, ':aid', $aid);
oci_bind_by_name($stid, ':shortName', $shortName);
oci_bind_by_name($stid, ':description', $description);
oci_bind_by_name($stid, ':type', $type);
oci_execute($stid);
$total = oci_fetch_assoc($stid)['TOTAL'];
print $total."\n";
?>
,打印4(錯誤)
有趣的是當我在Oracle在同一個表同一數據庫中,我得到1如預期(只有1個一行應匹配) 。
SQL> var aid number
SQL> var shortName varchar2(254)
SQL> var description varchar2(4000)
SQL> var type varchar2(254)
SQL> begin
2 select 1,'TroubleMgt','Trouble Management','TroubleMgt' into :aid,:shortName,:description,:type from dual;
3 end;
4/
PL/SQL procedure successfully completed.
SQL> select count(*) TOTAL from aradmin.activities where aid = :aid and shortName = :shortName and description = :description and type = :type;
TOTAL
----------
1
任何援助將不勝感激!
那麼,查詢看起來像平等,參數也是如此。然後1只看到兩個可能性1)你的PHP scritp連接到不同的數據庫2)在腳本中的'select count(*)'之前有一些插入。嘗試鎖定表,然後你可以檢查點2.嘗試重命名錶,你可以檢查點1 –