$get_months = '201405';
$begin = $merge . '-' . $merge_part . '-01'; //show 2014-05-01
$final = $merge . '-' . $merge_part . '-31'; //show 2014-05-30
$sql = "SELECT gendocs.idDocument as `No`,
CASE gendocs.idAddUser
WHEN 1 THEN 'AT'
WHEN 2 THEN 'VF'
WHEN 3 THEN 'IP'
WHEN 4 THEN 'SZ'
WHEN 5 THEN 'VA'
END as `agent`,
gendocs.documentDate ,
gendocs.documentType as pi ,
rservdocs.documentType as cdn,
gendocs.documentNumber ,
CASE gendocs.idCustomer
WHEN 0 THEN
(SELECT corporates.company
FROM corporates
WHERE corporates.id=gendocs.idCorporate )
ELSE
(SELECT group_concat(customers.firstname,' ', customers.lastname)
FROM customers
WHERE customers.id=gendocs.idCustomer )
END as 'client'
FROM zzz_reservationservicedocumentgenerateddocs_" . $getmonth . " as gendocs
JOIN zzz_reservationservicedocuments_" . $getmonth . " as rservdocs
ON rservdocs.id=gendocs.idDocument
WHERE
gendocs.documentDate>='" . $begin . "'
AND gendocs.documentDate<='" . $final . "'
AND gendocs.annulTime=0
AND (gendocs.documentType='P' OR gendocs.documentType='I')
AND (rservdocs.documentType='CREDIT'
OR rservdocs.documentType='DEBIT'
OR rservdocs.documentType='NORMAL')
ORDER BY gendocs.documentDate DESC
";
$query = $this->db->query($sql);
var_dump($query);
您好。当我在sql中删除php变量时,查询正常工作。 $ getmonth以整数格式201406输入 $ begin为日期添加字符串格式。
我尝试使用转义功能,不同的{},&#39;&#39;,&#39; \&#39; ... 没有。只是从不工作。