1
我正在製作預訂系統,因此我需要能夠在讓用戶預訂前查看是否有時隙(我的功能還在前後添加了1個時隙以檢查涵蓋旅行時間等)在phpmyamdin中查詢但在腳本中不能查詢
function timeSlotAvailable($date, $time){
$timeslots = array($time - 1, $time, $time + 1);
$slots = join(',',$timeslots);
$STH = $this->database->prepare("SELECT COUNT(*) FROM bookings WHERE bookings.date = :bdate AND bookings.slot IN (:ids)");
$STH->execute(array(":bdate"=>$date, ":ids"=>$slots));
$data = $STH->fetchColumn();
return "checking date:".$date." for slots ".$slots." the count is ".$data;
}
輸出
checking date:02/15/2014 for slots 3,4,5 the count is 0
現在bookings
還有就是正在使用該日期時間段4.然後我試圖在phpMyAdmin
SELECT COUNT(*) FROM bookings WHERE bookings.date = "02/15/2014" AND bookings.slot IN (3,4,5)
基本上是相同的查詢(提交相同的變量),但回報也可能隨着1
正確的響應。這讓我覺得我的代碼有些問題是我看不到的。
可能:bookings.date = 「2014年2月15日」 – Hackerman
它是在2014年2月15日數據庫。這會有所作爲嗎? – Harry
您是否將您的日期存儲爲varchar ?? .... holy molly ... – Hackerman