如何UpdateAll与hasMany关系?
我正在尝试更新所有颜色集。当我将数据读入表单时,表被添加,但是当我尝试写回它时,表没有被连接。
警告(512):SQL错误:1054:“字段列表”中的未知列“Fanpage.Colourset”[CORE/cake/libs/model/datasources/dbo_source.php,第684行]
查询:
UPDATE `fanpages` AS `Fanpage`
LEFT JOIN `users` AS `User` ON (`Fanpage`.`user_id` = `User`.`id`)
LEFT JOIN `accounts` AS `Account` ON (`Fanpage`.`account_id` = `Account`.`id`)
SET `Fanpage`.`Colourset` = Array, `Fanpage`.`Fanpage` = Array
WHERE 1 = 1
模型、控制器、表等的代码这里:http://bin.cakephp.org/view/1132666511
当我使用 SaveAll() 时,记录被添加到 colorset 表中,但是当我尝试 updateAll() 时,colorset表似乎不可用。
(抱歉,代码很乱 - 我是新人:))
感谢任何帮助 - 我已经用谷歌搜索了 2 天,但我无法弄清楚问题是什么。我尝试过改变关系等等。
I'm trying to updateall for coloursets. When I read the data into the form, the table is added, but when I try to write back to it, the table isn't joined.
Warning (512): SQL Error: 1054: Unknown column 'Fanpage.Colourset' in 'field list' [CORE/cake/libs/model/datasources/dbo_source.php, line 684]
Query:
UPDATE `fanpages` AS `Fanpage`
LEFT JOIN `users` AS `User` ON (`Fanpage`.`user_id` = `User`.`id`)
LEFT JOIN `accounts` AS `Account` ON (`Fanpage`.`account_id` = `Account`.`id`)
SET `Fanpage`.`Colourset` = Array, `Fanpage`.`Fanpage` = Array
WHERE 1 = 1
code for models, controllers, tables etc here: http://bin.cakephp.org/view/1132666511
When I had used SaveAll(), the records were added to the colourset table, but when I try updateAll(), the colourset table doesn't seem to be available.
(sorry for the messy code - I'm new :) )
Any help is appreciated - I've been googling for 2 days and I can't figure out what the problem is. I've tried changing the relationship etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是 updateAll 的用途,请使用 saveAll。
that's not what updateAll is used for, use saveAll.