![]() |
DataMapper saving multi-field join table - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: DataMapper saving multi-field join table (/showthread.php?tid=56949) |
DataMapper saving multi-field join table - El Forum - 02-01-2013 [eluser]msteudel[/eluser] I have the following tables: Code: Scenarios I'm trying to figure out how to save this sort of relationship ... I tried something like this: Code: $site = new Site(); I get this error: Code: Unable to relate scenario with location. Can anyone point me int he right direction. TIA DataMapper saving multi-field join table - El Forum - 02-01-2013 [eluser]msteudel[/eluser] I also tried something like: Code: $var = array( But got this error: Quote:Unable to relate scenario with site_id. DataMapper saving multi-field join table - El Forum - 02-01-2013 [eluser]msteudel[/eluser] I realized that I'm probably suposed to do it more like this: Code: // no id in name and pass in objects probably But I get Quote:Unable to relate scenario with location. DataMapper saving multi-field join table - El Forum - 02-03-2013 [eluser]WanWizard[/eluser] Datamapper doesn't support a through-table or relationship table with more than two foreign keys. You will have to split the many-to-many relations, by creating a model for the through table, and create one-to-many relations to this table. It will make maintaining the relations a bit more complex though. DataMapper saving multi-field join table - El Forum - 02-03-2013 [eluser]msteudel[/eluser] Thanks for the reply WanW, I'll give that a try and see how it goes ... maybe i'll just use sql for maintaining this .... |