在MySql Workbench上,sql可以正常工作。
SELECT id, hours,
CONVERT(DATE_FORMAT(hours, '%H'), SIGNED) AS intHours,
CONVERT(DATE_FORMAT(hours, '%i'), SIGNED) AS intMinutes
FROM jobdone_work_hours
Phalcon(1.3.4)显示错误
$result = $mm->executeQuery(
"SELECT id, hours,
CONVERT( DATE_FORMAT(hours, '%H'), UNSIGNED ) AS intHours,
CONVERT( DATE_FORMAT(hours, '%i'), UNSIGNED ) AS intMinutes
FROM SoilTechJobDone\Api\Models\JobdoneWorkHours
WHERE fk_staff_id = :staffEmpId:
AND confirmed='1'
AND date BETWEEN :dateStart: AND :dateEnd:
order by date",
[
'staffEmpId' => $staffEmpId,
'dateStart' => $dateStart,
'dateEnd' => $dateEnd,
]
);
Phalcon错误:
Syntax error, unexpected token AS, near to ' a, UNSIGNED ) AS intHours, CONVERT( DATE ...
他不喜欢的东西。
最佳答案
Phalcon PHQL不是1:1 MySQL。 Phalcon可能不知道DATE_FORMAT或CONVERT。 Phalcon 1.3.4像几年一样不受支持,因此我无法真正为您提供帮助,在phlcon 3中,可以选择添加扩展名以方言它被PHQL识别(类似于DQL)。
关于php - Phalcon-语法错误,意外的 token AS,靠近'a,UNSIGNED)AS intHours,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42863923/