简体   繁体   English

CakePHP在现有表中添加新的模型关联

[英]CakePHP Adding new model association to existing table

I have table foos and bars with a lot of data currently in them (well over 10,000 rows). 我有表foos和bar,其中有很多数据(远超过10,000行)。 I have now added a new relationship in the model Foo belongsTo Bar and Bar hasOne Foo . 现在,我在Foo belongsTo Bar模型中添加了一个新关系,关系为Foo belongsTo BarBar hasOne Foo

I would now need to add columns foo_id and bar_id to the tables but how can I populate the columns easily with the existing data? 我现在需要将foo_id和bar_id列添加到表中,但是如何用现有数据轻松填充列? I can't simply grab the data in cakePHP as the data array is too large. 由于数据数组太大,我不能简单地在cakePHP中获取数据。 Is there a way to do this using mySQL or from the cake console? 有没有办法使用mySQL或从Cake Console做到这一点?

我可能会通过基于SQL的迁移来解决此问题,或者如果这无法正常工作,那么使用foo和bar分页的Cake shell命令会将数据添加到新列中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM