![]() |
[Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) (/showthread.php?tid=18196) |
[Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 06-17-2009 [eluser]OverZealous[/eluser] 1) Is it saving any relationships? 2) Does $b->save($d) work? 3) Are you able to save brainstorms manually, without the HTML form / submit? 4) Are you certain that $model and the $has_many item are spelled the exact same, on both models? I know you said you looked, but make sure there aren't any typos. Also, this assumes you are using standard, simple relationships, not the advanced relationships. 5) Have you tried outputting the queries using $d->db->last_query(), or even better, enabling the CI profiler, and looking through all of the queries? 6) Also, just because error is empty, doesn't mean that something didn't go wrong. When saving relationships, for example, you may get a FALSE response, but no error message. This means that the attempt to save the relationship failed, usually either $d or $b (in your example) are not defined (ie: do not have an ID set), or that the relationship is improperly defined. This is what I mean by not enough information. Saying that $a->save($b) doesn't work just tells me that the problem is on your end. Obviously that code snippet isn't the issue, or no-one could use DMZ. (BTW: here's a smiley, I'm not angry :-P) [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 06-19-2009 [eluser]Matthew Lanham[/eluser] @OverZealous Can you tell me if there is a way to force insert rather than update, the reason i ask is that as soon as i specify an id it automatically assumes it's an update, however on this particular data i am inputing i want to preserve the id from another database. [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 06-19-2009 [eluser]OverZealous[/eluser] Nope. You cannot use DataMapper to do that. You might be able to hand copy out the chunk of code that does the insert (see the save() method), and paste it into your own Extension. It shouldn't be too difficult. Also, this is in the FAQ: Why can I not save an item with a specific ID? [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 06-19-2009 [eluser]tdktank59[/eluser] @Overzealous Just took a look again... Heres the modified code to remove any doubt of anything not working... Code: $d = new Dqip(); It prints out Quote:{#} is an actual number This is still not saving. I turned the profiler on and all it is doing is grabbing the brainstorm and the dqip. However it is not saving them... I also checked to make sure the join table is spelled right "join_brainstorms_dqips" which if im not mistaken the correct spelling and way of doing it... Brainstorm Model: Code: class Brainstorm extends DataMapper Dqip Model: Code: class Dqip extends DataMapper UPDATE: I am now doing a work around with active record instead of using datamapper. It is inserting properly... Code: $this->db->set('brainstorm_id',$b->id)->set('dqip_id',$d->id)->set('created_on',time())->insert('join_brainstorms_dqips'); [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 06-19-2009 [eluser]OverZealous[/eluser] @tdktank59 Do you have trouble saving any other relationships? Or just this one? Crap, accidentally submitted I recommend backing up the current libraries/datamapper.php file, and replacing it with the one attached. This will allow you to see what's happening with the save. It may not show anything, in that case, DMZ doesn't see any object to save in the ->save() command, for some reason. -- test file deleted -- [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 06-19-2009 [eluser]tdktank59[/eluser] Haven't tried saving any other relations... Basically every other one is a many to one relation which exists on the parent table... Ill see if I can get another relation working... Heres what its printing out Quote:Saving a dqip: However it is not inserting it into the db... [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 06-19-2009 [eluser]OverZealous[/eluser] Well, something is wrong in your setup, because "Related Properties" is coming back empty. You don't have the "Production Cache" enabled, do you? Please don't enable that unless you are ready to go to production. [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 06-19-2009 [eluser]tdktank59[/eluser] Woops... Thought I had turned that off... Heres the new results Quote:Saving a brainstorm: And wada ya know! Turning off the cache now saves the relationship... Im guessing its because the cache did not have the relation... * I feel stupid now btw... * It is working now!!! [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 06-19-2009 [eluser]OverZealous[/eluser] There's a reason for those great big red sections at the top of the help documents ![]() Production Cache: Quote:Important: You must clear the cache for any model you make changes to, whether that is in the database or in the file. Failure to do so will most likely result in errors, and could possibly lead to data corruption. So, for a general clarification, don't use the production cache, unless you have a need for it. Note: I added this to the FAQs. [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 06-19-2009 [eluser]tdktank59[/eluser] I do have a need for it... But I thought I had turned it off and refreshed the cache when I updated the models... |