![]() |
[Deprecated] DMZ 1.5.4 (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.4 (DataMapper OverZealous Edition) (/showthread.php?tid=23751) |
[Deprecated] DMZ 1.5.4 (DataMapper OverZealous Edition) - El Forum - 11-15-2009 [eluser]OverZealous[/eluser] This is the very first item on the troubleshooting page. http://www.overzealous.com/dmz/pages/troubleshooting.html#Database.UnknownColumn Please check the manual when you have problems. [Deprecated] DMZ 1.5.4 (DataMapper OverZealous Edition) - El Forum - 11-16-2009 [eluser]pesho_h_k[/eluser] Hello, when I create a user - password and confirm password fields are OK, but when I want to update just one field (the "Active" field, when user confirms from link on the mail) - it always alerts me that password and conf. password do not match ... but the user doesn't enter them ... I just want to update one field ... ![]() how do you deal with this?? [Deprecated] DMZ 1.5.4 (DataMapper OverZealous Edition) - El Forum - 11-16-2009 [eluser]OverZealous[/eluser] As long as you are selecting all of the fields, DMZ should automatically pre-fill-in 'matches' columns. If you are trying to modify the password column via code, then obviously you must fill in both the password and confirm_password field in your code. (DMZ doesn't know how the fields were set, it just validates them according to your rules.) Check the example code again, and make sure you haven't made any changes. I use the matches column on a user account currently, and have no trouble with the matches columns. I also just tested it with the DMZ Example application that is included with the DMZ download. It also has no problems. [Deprecated] DMZ 1.5.4 (DataMapper OverZealous Edition) - El Forum - 11-20-2009 [eluser]teddy3[/eluser] http://www.overzealous.com/dmz/pages/advancedrelations.html hello, I followed Multiple Relationships to the Same Model on the link above, but one thing is not working. after I set relationship between user and post as creator and editer, this method shows error. Code: $post= new Post(); if I run $this->creator->get(), it shows an error that join table does not have 'user_id' column. of course there is no user_id, there are only 'creator_id', 'editor_id'. Code: $post = new Post(); this one works perfect though ![]() please let me know if i am wrong. thanks [Deprecated] DMZ 1.5.4 (DataMapper OverZealous Edition) - El Forum - 11-20-2009 [eluser]OverZealous[/eluser] @teddy3 Without seeing more code, my guess is that you have the relationship misconfigured on one side of the relationship, and not the other. Your relationship has to be defined on both sides (ie: both for Post and for User as Creator (as well as User as Editor). The relationships should look symmetrical. The reason I think this is the case is that it works from include_related, but not ->creator. When DMZ is looking up the relationship, it uses the same code, but in the second case (the broken one) it is looking at it from the point of view of the Creator(User) class, where as the first one it is looking at the relationship from the point of view of the Post class. If you are still having trouble, can you please provide me this information: • The $has_one array from Post • The $has_many array from User • The DB schema for the join table • The result of $post->creator->check_last_query(); You don't necessarily have to paste these into the forum - you can PM me so the forum isn't cluttered. The example application has the same relationships (between bugs and users), however, it uses In-Table Foreign Keys (ITFKs), so I can't easily check for errors. [Deprecated] DMZ 1.5.4 (DataMapper OverZealous Edition) - El Forum - 11-20-2009 [eluser]teddy3[/eluser] you are right There's a misspelled key in model :-) it works damn well thank you!! [Deprecated] DMZ 1.5.4 (DataMapper OverZealous Edition) - El Forum - 11-21-2009 [eluser]Mirage[/eluser] Alright - my head hurts. Someone help me figure out how to set this up. I have 3 tables: plants, images and plant_images - One plant can have many (0-n) images - Each image though, really ever has one plant The images table is generic. It’s not only bound to plants. It just hold information about the image resources and has images that have nothing to do with plants at all. So I guess plant_images is not really a n:n relationship but really 1:n relationship to plants. But it’s also a 1:1 relation ship with images (if one exists). I need some suggestion on how to set up the models for this and how to maintain the records in the plant_images table as it should change when I add/remove plants as well when I add/remove images (for a plant). Any help would be much, much appreciated. Regards, m [Deprecated] DMZ 1.5.4 (DataMapper OverZealous Edition) - El Forum - 11-21-2009 [eluser]Mirage[/eluser] So I do have this right now: Code: class Plant extends DataMapper { Code: class Image extends DataMapper { I am assuming that I do not have to make a model for the plant_images relation. Now in a synchronization loop for image resources I have the following: Code: foreach ($result as $key => $file) This will properly save/update the images. But there are two problems: 1. The plant model insists on the relation being called images_plants. Is there a way to customize this? 2. The call to $plant->save($image) will not create a relation to images_plants. Pointers, please? Thanks, -m [Deprecated] DMZ 1.5.4 (DataMapper OverZealous Edition) - El Forum - 11-21-2009 [eluser]OverZealous[/eluser] [quote author="Mirage" date="1258857856"] This will properly save/update the images. But there are two problems: 1. The plant model insists on the relation being called images_plants. Is there a way to customize this? 2. The call to $plant->save($image) will not create a relation to images_plants. [/quote] You haven't set things up correctly. You cannot have a relationship defined only in one way. You have to define both the plant AND the images relationship. You cannot change the name of join tables. The algorithm for determining join table names is hard coded. The names must be in alphabetical order. If you want images to be associated with one plant, then you either create an "images_plants" table, with the columns "id", "image_id", and "plant_id", or you add the column "plant_id" to the "images" table. For the latter, simply set the default value to NULL and allow NULLs, and then you have a ready-made $has_one relationship. I think, even though Images is used in more than one place, it makes much more sense to use an ITFK for this setup. [Deprecated] DMZ 1.5.4 (DataMapper OverZealous Edition) - El Forum - 11-21-2009 [eluser]Mirage[/eluser] Ok... bear with me while I'm having a conversation with myself... It turns out that I needed to let images know about the relationship as well, even though images aren't always related to plants: Code: class Image extends DataMapper { So this makes my saving code work now. However, I'm still not liking that the relationship has to be called images_plants rather plants_images. Why is this? I was looking at the bugs sample app and see that the table there was bugs_users rather than users_bugs. Why one over the other and what's the rule and can it be broken? Thanks, -m |