我一直在搜索我尝试访问CakePHP烘焙页面时出现的问题的一些答案,而且我仍然收到此错误:
错误:SQLSTATE [42S22]:未找到列:1054未知列'方坯。 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直接烘焙,因此我没有任何行显示查询是如何完成的。
答案 0 :(得分:0)
您在此行上缺少刻度线,并且AS
名称中有一个额外的空格:
`Billet. user_id` AS `Billet__ user_id`,
应该是
`Billet`.`user_id` AS `Billet__user_id`,
这一行也是如此:
`Billet` INNER JOIN `users` `Users` ON `Users`.`id` = (`Billet. user_id`) LIMIT 20 OFFSET 0
应该是
`Billet` INNER JOIN `users` `Users` ON `Users`.`id` = (`Billet`.`user_id`) LIMIT 20 OFFSET 0