doukan3504 2014-10-23 14:40
浏览 100
已采纳

PDO查询无效

I am trying to run a simple SELECT query. here is the query

$sql1=$conn->prepare("SELECT q.quoteid, q.customername, q.customersurname, q.timestamp, o.name 
FROM quotes as q, occasions as o 
WHERE q.occasionid=o.occasionid 
AND companyid=1 
AND q.day=:day 
AND q.month=:month 
AND q.year=:year 
AND staffid='-1' 
AND (q.complete != 'W' OR q.complete != 'Y') 
AND q.online=0");
$sql1->execute($exearray);
/* here  $exearray contain following value */
Array ( [:day] => 24 [:month] => 1 [:year] => 2014 ) 

Its not even showing any error. If I pass static value 1 in month it is showing data. I run this query directly on DB its working.

So I think there is no error in query. I am running this query locally on MAMP.

  • 写回答

4条回答 默认 最新

  • dongyou9818 2014-10-23 15:35
    关注

    In table month column type was Varchar. I change that to integer and now it is working.

    p.s. I have tried using (string) before variable and even double quotes and single quotes on variable value but it didn't work.

    Thank you everyone. :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度