![]() |
DMZ 1.7.1 (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: DMZ 1.7.1 (DataMapper OverZealous Edition) (/showthread.php?tid=28550) |
DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 10-14-2010 [eluser]tomdelonge[/eluser] How can you search on a relationship? For example, if I have posts and each post as one author, searching for "ada" should return any posts written by "adam". Maybe this isn't the best example... But I need to search on a table where each record has one in another table (I need to search on the "other" table's columns) DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 10-14-2010 [eluser]OverZealous[/eluser] @tomdelonge Please see the where_related functions on the Get Advanced page. Ex: Code: $post->like_related('user', 'ada', 'after')->get(); DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 10-16-2010 [eluser]WanWizard[/eluser] Phil, Thanks to all the work you've put in to make DMZ a great tool to work with! As I understand, two other people besides me have come forward to take it over from you. I personally feel that forking this three-ways isn't very productive, so I think the three of us have to see how we are going to move on with Datamapper. Any suggestions? DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 10-16-2010 [eluser]defeed[/eluser] I'm adding a new movie and there is a text input to enter genre. How can I check if the given genre already exists in the 'genres' table thus relate a new movie to that genre by '$movie->save($genre)', otherwise add a new genre and then relate it to the movie by doing '$genre->save(); $movie->save($genre)'? Anyone, please? DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 10-16-2010 [eluser]WanWizard[/eluser] Something like Code: $genre = new genre(); DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 10-16-2010 [eluser]defeed[/eluser] Thanks, it worked! And maybe the last question (sorry for abusing you ![]() If I enter several genres delimited by comma, how could I break this string to a separate genres and relate them all to a movie, creating non-existent genres? DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 10-17-2010 [eluser]alaminx[/eluser] I have some trouble in save related data: The country have many city city has country_id key When I try to save country to city. The data saved in country_id field is NULL. This is model: Code: <?php Code: <?php And the add method: Code: function add() Help me please ! DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 10-17-2010 [eluser]WanWizard[/eluser] You're overloading the save() method of the Datamapper object. Not a problem, but take into account that the save method can have parameters, which you ignore here. So if you do this, it won't work: Code: $county = new Country(1); DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 10-17-2010 [eluser]alaminx[/eluser] oh. I'm fool. Forget the save method's parameters. Thanks so much ! DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 10-18-2010 [eluser]johlin[/eluser] I've just moved to DMZ from ignitedrecord and I really like how the validation is integrated, but I can't quite figure out how to make my relationships work. I have on table for users and one for orders. The order table has got a field called userid which cannot be changed (the database is already in use by another application). Also, I can't quite figure out how to choose between a belongs_to and has_one-relationship. How would I set that relation up so that a user can have many orders and orders belong to one user? |