![]() |
[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 - 09-22-2009 [eluser]cahva[/eluser] I tested this now with a fresh install of CI 1.7.2 and latest DMZ 1.5.3 with the example application. It will log you in if you just remove the password input from the form and put existing user to the username field: Login view with just password commented out: Code: echo $user->render_form(array( I know I wasnt crazy ![]() It wont login if there is a password field in the form, so empty or wrong password wont let you in. This happens if you remove the password field from the form. So its a potential security hole when you could for example just send the form from outside without password field. My setup is Wampserver with PHP5.3, mysql 5. I tested this just by copying fresh CI in c:/Wamp/www/ folder, set the config.php, database.php. Then copied from the latest DMZ datamapper files and finally copied the example application folder. [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 09-22-2009 [eluser]Jinkusu[/eluser] Need some help here. The User Guide has been very helpful and I've been able to get my project off the ground so far but I've encountered an issue with setting up some advanced relationships. The issue is my table called User which has 4 diff models User, Lecturer, Guardian and Admin. Not only that the guardian has a many-to-one relationship with the user. How exactly do u set this up because i can set up a self relationship and a multiple relationship to same model but how do u go about doing a combination of the 2? User Model Code: class User extends DataMapper { Student Model Code: class Student extends User { Guardian Model Code: class Guardian extends User { NB i want to link the Guardian and Student via guardian_id Thanks. [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 09-22-2009 [eluser]OverZealous[/eluser] [quote author="Jinkusu" date="1253685933"]The issue is my table called User which has 4 diff models User, Lecturer, Guardian and Admin. Not only that the guardian has a many-to-one relationship with the user. How exactly do u set this up because i can set up a self relationship and a multiple relationship to same model but how do u go about doing a combination of the 2?[/quote] @Jinkusu The simplest solution, and I think the most flexible, is to have only one User model. Use flags (booleans or smallint values) to determine what type of user someone is. I wouldn't bother having a different Class for each type of user. It will just make your life very difficult. Then, set the self-relationship up like normal. Enforce the relationship in your code, not through complex models. Code: class User extends DataMapper { Usage might be like this: Code: $guardian = new User(); [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 09-22-2009 [eluser]OverZealous[/eluser] @cahva Seeing as I can't seem to replicate it here (I even switched to MySQL to try), I can't really do much to change it. I don't want to change the example code for now, because I think the code I have is correct. There's nothing wrong in adding the extra check, it just shouldn't be necessary. I'll keep an eye on it, though, to see if I can figure out how it is happening. [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 09-23-2009 [eluser]Jinkusu[/eluser] @OverZealous Thanks for the suggestion, i think i might try that approach as it seems much simplier, but one issue though, how do you set up the table? My assumpiton: join_guardians_students id | guardian_id | student_id Also when creating the relationship: Code: $guardian = new User(); Thanks. [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 09-23-2009 [eluser]introvert[/eluser] How can I do this with DMZ: Code: $this->db->where('id', $_POST['id']); Thanks for help! [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 09-23-2009 [eluser]Jinkusu[/eluser] [quote author="introvert" date="1253751936"]How can I do this with DMZ: Code: $this->db->update('items', $_POST); [/quote] What exactly are you trying to do here, update the database with info from your form? If so you can either go through all the fields like: Code: $object = new ObjectType(); OR an array: Code: $object = new ObjectType(); Either way be sure to load the html helper Code: $this->load->helper('html'); [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 09-23-2009 [eluser]introvert[/eluser] Isnt it better to just use $_POST instead of writing array with each of the values? Also, is it neccessary to call save at the end - it doesnt seem to be when I test it.. [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 09-23-2009 [eluser]Jinkusu[/eluser] [quote author="introvert" date="1253752821"]Isnt it better to just use $_POST instead of writing array with each of the values? Also, is it neccessary to call save at the end - it doesnt seem to be when I test it..[/quote] I'm assuming the name of each of the Posted items is the same as the column name? Either was i'm not aware of a function that does this, and i don't believe that's a secure way to update your DB as using the same column name as an input name is just asking for trouble. Regarding the save(), i honestly couldn't tell you, I think its just a good habit though. [Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) - El Forum - 09-23-2009 [eluser]introvert[/eluser] I have one more question regarding relations.. I have 4 tables: blogs campaigns feeds items The relations are: blog belongs to campaign (one-to-one) each feed belongs to 1 campaign each item belongs to 1 feed Now if I have item id and I want to get the blog record that belongs to the same campaign as the feed of that item, I should retrive the parent's feed_id from item.feed_id and then campaign_id from feed.campaign_id and then find the proper blog.campaign_id This sounds pretty complicated design and I have some concerns if it would be better to just store the campaign_id with each item so that I can then just join blogs and items tables by campaign_id? How would you design that? I dont want to duplicate data and make it hard to control so I should probably go for something like: Code: SELECT blogs.* But how can I write that with DMZ? Many thanks in advance! |