【发布时间】:2016-09-19 15:59:37
【问题描述】:
我一直在寻找一些解决方案,以解决在尝试访问使用 CakePHP 烘焙的页面时出现的问题,但我仍然收到此错误:
错误:SQLSTATE[42S22]:未找到列:1054 未知列 'Billet. '字段列表'中的 user_id'
这是 Cake 创建的查询
SELECT `Billet`.`id` AS `Billet__id`,
`Billet`.`created` AS `Billet__created`,
`Billet`.`updated` AS `Billet__updated`,
`Billet. user_id` AS `Billet__ user_id`,
`Billet`.`title` AS `Billet__title`,
`Billet`.`tags` AS `Billet__tags`,
`Billet`.`content` AS `Billet__content`,
`Users`.`id` AS `Users__id`,
`Users`.`username` AS `Users__username`,
`Users`.`password` AS `Users__password`,
`Users`.`name` AS `Users__name`,
`Users`.`lastname` AS `Users__lastname`,
`Users`.`birthdate` AS `Users__birthdate`,
`Users`.`email` AS `Users__email` FROM `billet`
`Billet` INNER JOIN `users` `Users` ON `Users`.`id` = (`Billet. user_id`) LIMIT 20 OFFSET 0
查询的代码是直接由 Cake 烘焙的,所以我没有任何行来说明查询是如何完成的。
【问题讨论】:
-
请显示您在 Cake PHP 中使用的创建查询的任何代码...
-
肯定是在
Billet__ user_id和Billet. user_id中添加了一个空格。 -
正如我在下面所说的,代码是直接由 Cake 烘焙的,所以我不认为(在检查后我确定我没有任何明确的查询代码)有任何代码来自干扰的我
-
@DevNewb 如果在 Cake 的代码中恰好有一个
\n正在生成您的查询,那么这也可能是空间的原因。我以前从未听说过这种行为,除非在某处对某些代码进行了某种更改。 -
数据库中的列名可能包含前导空格。
标签: php mysql cakephp-3.0