Datamapper relationship will read, but not save - 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 relationship will read, but not save (/showthread.php?tid=60014) |
Datamapper relationship will read, but not save - El Forum - 12-27-2013 [eluser]Dracos[/eluser] This is a rather complex relationship that got coded up a long time ago, but only now is coming into use. The system is using CI 2.1 and DM 1.8.2. Here are the model snippets: Code: class contact extends DataMapperExt { So far, the file model is only being used for images; contact is only one model (of about 8) to have such a relationship with file, and the first to have it implemented. The tables involved are "files" (of course), "contacts" (of course), and for this relationship "contacts_images". All the other similar $has_many relationships in file use a "[foo]s_images" table. Using this: Code: $c = new contact($some_id); I can get the image (nee file) correctly, if contact::has_one['image']['other_field'] = 'image_contact'. I know this works because I manually created the row in contacts_images. I know 'other_field' breaks it because I commented it out; commenting out contact::has_one['image']['join_other_as'] made no difference. However, this: Code: $c = new contact($some_id); Results in nothing ever happening in the contacts_images table... no insert, no update. Contact has a custom save(), in which I've placed some logging... I see it being called with $related = "image". Where did this go wrong? I remember there was a reason why class "File" isn't named "file", but I don't remember what that was. Invoking "new file()" seems to work just fine. |