![]() |
[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 - 08-04-2009 [eluser]naren_nag[/eluser] UPDATE: So here's how I fixed this bug. I have a method in a controller where I start building a query. Then I pass the object to a helper where I continue to build the query (chaining various things together). In the helper I also create another object to get all the groups the current user belongs to. And that's where things fell apart. At least when you're in the helper, it looks like you can't pass an object and create a new object there. Now, I can't figure out why this should be, so I have to be missing something here. If anybody would like to try and pick this apart with me, I'm game. For the moment I have fixed this by getting the list of groups in the controller and passing it to the helper function. cheers, naren [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 08-04-2009 [eluser]tdktank59[/eluser] Just finished reading up on the new stuff and now updating a few queries... heres one that has stumped me thus far. (Even stumped me on the last version too) Code: $sql = "SELECT `problems`.`id`, Heres what I was using (thanks OverZealous for the help on this one too!) Code: $problem = new Problem(); The select statement is not that important but those are the values I am using... And the above DMZ code is throwing this error From the looks of it, its not doing any of the joins... Quote:A Database Error Occurred Ill continue trying to get this to work... However Im pretty stumped in how to do this... [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 08-04-2009 [eluser]OverZealous[/eluser] @naren_nag My guess is that you have two classes with the same name somewhere. When you create the new object, it isn't a DataMapper object, but whatever the alternate is (ie: a controller, library, or something else that has the same name as the DM model). @tdktank59 I can't see what exactly is wrong, but my guess is that the query is getting cleared somehow. It usually happens when you look up an object while building a query, which can be tricky, like this: Code: // Example of what NOT to do The call to $widget->get_by_id will have reset the query. Instead, always load all of your objects at once, and build the query after, like this: Code: // Example of what to do Also, I think you should be able to safely change this: Code: // create special query section to this: Code: $problem->group_start() (Don't forget to replace all the join_related method calls with include_related. I plan on removing join_related completely when I eventually move to DMZ 2.x (but that could be years. ;-) ) [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 08-04-2009 [eluser]bEz[/eluser] @phil Using 1.4.0 (I know about 1.4.1) I know you're going to fine me for not providing enough info, but trust me, I'm checking the naming conventions and relationships where possible. Anyhow, I have used FIREPHP to log the fact that I am successfully instantiating a model object, view the data retrieved (get), as well as able to assign new data to the object. However, when I perform a save(), I am getting the following error: Code: Fatal error: Class name must be a valid object or a string in C:\home\furious4\ci\rr\application\libraries\datamapper.php on line 1553 I am pulling my hair out, as I've tried doing this with use of the new extensions, and even now back to bare bones assignment. -bEz [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 08-04-2009 [eluser]bEz[/eluser] [quote author="bEz" date="1249435679"]@phil Using 1.4.0 (I know about 1.4.1) I know you're going to fine me for not providing enough info, but trust me, I'm checking the naming conventions and relationships where possible. Anyhow, I have used FIREPHP to log the fact that I am successfully instantiating a model object, view the data retrieved (get), as well as able to assign new data to the object. However, when I perform $obj->save(), I am getting the following error: Code: Fatal error: Class name must be a valid object or a string in C:\home\furious4\ci\rr\application\libraries\datamapper.php on line 1553 I am pulling my hair out, as I've tried doing this with use of the new extensions, and even now back to bare bones assignment. -bEz[/quote] Just to let you know, my fix to this issue was to do the following: Code: $obj->skip_validation()->save(); [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 08-04-2009 [eluser]OverZealous[/eluser] @bEz The only reason to see that error is that you have a typo in the class name of one of your relationships. Just looking at the DMZ source code sees that that line occurs here: Code: // In count() The reasons your workaround works is you aren't validating the input, which means you are not validating a relationship rule (such as required), and therefore DMZ isn't counting the related records. The error will be found on the child object, so that if you are doing this: Code: $object->save($child); [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 08-04-2009 [eluser]bEz[/eluser] Ok, let me check the validation definitions so that I can close this trouble ticket ![]() [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 08-04-2009 [eluser]OverZealous[/eluser] * The error would be in the $has_one or $has_many arrays. [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 08-04-2009 [eluser]tdktank59[/eluser] Allright got it working! However here is the dmz code Code: $problem = new Problem(); The include_related does not work for some reason... (might want to look into that?) and for some reason the sql this generates is this: Quote:SELECT `problems`.* It works but should it also be joining the users table twice??? (owner, assigned_to) [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 08-04-2009 [eluser]OverZealous[/eluser] @tdktank59 The join_related function calls include_related. It no longer does anything. There is no reason it would work differently. I do not see where you are joining a user table in your example code. |