我正在使用cakePHP3,以下是当单价等于pdo绑定参数时用于获取数据的查询的调试。
'sql' => 'SELECT Dockets.id AS `Dockets__id`, Dockets.docketnum AS `Dockets__docketnum`, Branches.name AS `Branches__name`, Contacts.fname AS `Contacts__fname`, Contacts.lname AS `Contacts__lname`, Dockets.description AS `Dockets__description`, Dockets.quantity AS `Dockets__quantity`, Dockets.unitprice AS `Dockets__unitprice`, Dockets.status AS `Dockets__status`, Dockets.mailshipping AS `Dockets__mailshipping`, Dockets.mailorder AS `Dockets__mailorder`, ShippingForms.id AS `ShippingForms__id`, ShippingForms.status AS `ShippingForms__status`, VariablePrinterForms.start_prefix AS `VariablePrinterForms__start_prefix`, VariablePrinterForms.stop_prefix AS `VariablePrinterForms__stop_prefix` FROM dockets Dockets LEFT JOIN branches Branches ON Branches.id = (Dockets.branch_id) LEFT JOIN contacts Contacts ON Contacts.id = (Dockets.contact_id) LEFT JOIN shipping_forms ShippingForms ON Dockets.id = (ShippingForms.docket_id) LEFT JOIN variable_printer_forms VariablePrinterForms ON Dockets.id = (VariablePrinterForms.docket_id) LEFT JOIN lamdie_forms LamdieForms ON Dockets.id = (LamdieForms.docket_id) LEFT JOIN label_press_forms LabelPressForms ON Dockets.id = (LabelPressForms.docket_id) WHERE Dockets.unitprice = :c0 ORDER BY Dockets.docketnum desc LIMIT 25',
'params' => [
':c0' => [
'value' => '56.58',
'type' => 'float',
'placeholder' => 'c0'
]
但是此查询不会返回任何结果。 但是,如果我在phpmyadmin中使用相同的查询
SELECT Dockets.id AS `Dockets__id`, Dockets.docketnum AS `Dockets__docketnum`, Branches.name AS `Branches__name`, Contacts.fname AS `Contacts__fname`, Contacts.lname AS `Contacts__lname`, Dockets.description AS `Dockets__description`, Dockets.quantity AS `Dockets__quantity`, Dockets.unitprice AS `Dockets__unitprice`, Dockets.status AS `Dockets__status`, Dockets.mailshipping AS `Dockets__mailshipping`, Dockets.mailorder AS `Dockets__mailorder`, ShippingForms.id AS `ShippingForms__id`, ShippingForms.status AS `ShippingForms__status`, VariablePrinterForms.start_prefix AS `VariablePrinterForms__start_prefix`, VariablePrinterForms.stop_prefix AS `VariablePrinterForms__stop_prefix` FROM dockets Dockets LEFT JOIN branches Branches ON Branches.id = (Dockets.branch_id) LEFT JOIN contacts Contacts ON Contacts.id = (Dockets.contact_id) LEFT JOIN shipping_forms ShippingForms ON Dockets.id = (ShippingForms.docket_id) LEFT JOIN variable_printer_forms VariablePrinterForms ON Dockets.id = (VariablePrinterForms.docket_id) LEFT JOIN lamdie_forms LamdieForms ON Dockets.id = (LamdieForms.docket_id) LEFT JOIN label_press_forms LabelPressForms ON Dockets.id = (LabelPressForms.docket_id) WHERE Dockets.unitprice = 56.58 ORDER BY Dockets.docketnum desc LIMIT 25
它返回一堆结果。谁能告诉我为什么蛋糕没有在这里提供任何结果集。数据库中的字段设置为float(10,3)。
debugkit日志是
SELECT Dockets.id AS `Dockets__id`, Dockets.docketnum AS `Dockets__docketnum`, Branches.name AS `Branches__name`, Contacts.fname AS `Contacts__fname`, Contacts.lname AS `Contacts__lname`, Dockets.description AS `Dockets__description`, Dockets.quantity AS `Dockets__quantity`, Dockets.unitprice AS `Dockets__unitprice`, Dockets.status AS `Dockets__status`, Dockets.mailshipping AS `Dockets__mailshipping`, Dockets.mailorder AS `Dockets__mailorder`, ShippingForms.id AS `ShippingForms__id`, ShippingForms.status AS `ShippingForms__status`, VariablePrinterForms.start_prefix AS `VariablePrinterForms__start_prefix`, VariablePrinterForms.stop_prefix AS `VariablePrinterForms__stop_prefix` FROM dockets Dockets LEFT JOIN branches Branches ON Branches.id = (Dockets.branch_id) LEFT JOIN contacts Contacts ON Contacts.id = (Dockets.contact_id) LEFT JOIN shipping_forms ShippingForms ON Dockets.id = (ShippingForms.docket_id) LEFT JOIN variable_printer_forms VariablePrinterForms ON Dockets.id = (VariablePrinterForms.docket_id) LEFT JOIN lamdie_forms LamdieForms ON Dockets.id = (LamdieForms.docket_id) LEFT JOIN label_press_forms LabelPressForms ON Dockets.id = (LabelPressForms.docket_id) WHERE Dockets.unitprice = 56.58 ORDER BY Dockets.docketnum desc LIMIT 25 OFFSET 0
由于
答案 0 :(得分:0)
问题是表中的数据类型是float(10,3),因为搜索精确的float值需要一些额外的函数(比如FORMAT()等)来在mysql查询中使用。我将其更改为十进制(10,3),现在似乎完全搜索小数值。