如何避免来自sql查询的额外引号

时间:2015-10-28 07:35:38

标签: mysql sql zend-framework

$select->join($dtr, "$dt.TableId=$dtr.TableId AND "."$dtr.".'StartTime NOT BETWEEN '.'"'.$Time.'"', array(),'left');
             $select->where->equalTo("$dt.". 'SeatingCapacity', $wherearray['Size']);  

它给我这样的结果

 SELECT "dining_table"."TableId" AS "TableId", "dining_table"."TableName" AS "TableName", "dining_table"."StoreId" AS "StoreId" FROM "dining_table" LEFT JOIN "dining_table_reservation" ON "dining_table"."TableId"="dining_table_reservation"."TableId" AND "dining_table_reservation"."StartTime" "NOT" BETWEEN "\"""2015""-""10""-""15" "17"":""40"":""20" AND "2015""-""10""-""15" "17"":""40"":""20""\"" WHERE "dining_table"."SeatingCapacity" = '4'

但我希望时间格式为NOT BETWEEN '2015-10-15 17:40:20' AND '2015-10-15 17:40:20'

我该怎么办?

1 个答案:

答案 0 :(得分:0)

我已编辑了我的查询。请看看

<?php
$dtr="dining_table_reservation" ;
$dt="dining_table"; 
$time="2015-10-12 06:39:24";
$time2="2015-10-12 08:39:24";

$select->join($dtr, " ".$dt.".TableId=".$dtr.".TableId AND ".$dtr.".StartTime NOT BETWEEN '".$time."' AND '".$time2."' ", array(),'left');
             $select->where->equalTo("".$dt.".SeatingCapacity", $wherearray['Size']);