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 - 08-09-2010 [eluser]OverZealous[/eluser] @All Thanks for finding this bug and the fix. I'll make sure it gets into the next release of DMZ. DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 08-10-2010 [eluser]Daniel H[/eluser] [quote author="OverZealous" date="1281068626"]That being said, I'm pretty sure I've already determined out how to implement it with minimal impact to the library's performance.[/quote] No problem - if you need me to test this feature out then let me know. :-) DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 08-10-2010 [eluser]Unknown[/eluser] I think I've either found a bug or I'm not using it correctly. Basically what I want to do is search upon a join field between a many-to-many relationship. Here's the code needed to get a test working from a base CI and DMZ install. MySQL Tables & Data http://gist.github.com/518191 Attribute Model http://gist.github.com/518199 Product Model http://gist.github.com/518201 Controller http://gist.github.com/518207 If you browse to the base url, or /welcome/index, you will get the following error: Quote:A Database Error Occurred It's not adding the join for attributes_products. What I ended up doing was editing libraries/datamapper.php and in _join_field() at line 5309 I added a line: Code: // Determine relationship table name, and join the tables I've tried everything from include_related() to include_join_fields() and nothing seems to get the right outcome except this hack above. I've not tested it anywhere else, so I don't know the impact this change will have elsewhere. Am I doing it wrong or is this a bug? Any help is appreciated! EDIT: I noticed I used "or_ilike_join_field", since I copied it from a larger statement, but also "ilike_join_field" does not work DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 08-13-2010 [eluser]bonatoc[/eluser] Hello, Please, I need some help. I have countries and currencies. The relationship is : country has_one currency, with a currency_id column in countries When editing a country, I want to assign a currency to the country. I use the htmlform extension (I know it's not supported anymore, but maybe some of you guys use it). I pass this to render_form() : Code: $form_fields = array( I have a 'currency' pull-out menu generated, and everything's fine. Question : I have a 'Status' column in currencies, which is an ENUM set either to 'Active' or 'Inactive'. At the moment, when creating the $country object, it retrieves all of the currencies. How can I populate $country->currency with only currencies that are 'Active', and then passing it to $country->render_form() ? Can a subquery do the trick (the following does not work) ? Code: $country->include_related('currency')->where('Status','Active')->get_by_id($id); or am I forced to create a currency object, and then pass it explicitely to the form, thus unexploiting the automatization process htmlform() provides ? Thanks. DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 08-13-2010 [eluser]bonatoc[/eluser] I'm very interested in how you guys deal with ENUM switches on sub-objects. Because obviously there can be many DB items which one would like to retrieve based on their 'ON','OFF' statuses. Surely there must be a subquery technique which could avoid writing this : Code: // Get active currencies I define some strings as constants, no errors in this code. DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 08-14-2010 [eluser]kre8ivdesigns[/eluser] Ok Need some help: I have three table reservations id checkin checkout numberofpeople numberofdays days_reservations id reservation_id day_id days id day When someone comes to the site they will check availability. First I have the dates they chose to be matched to the days table to get the day_id Now how do I check if the day_id exists in the join table days_reservation to return to the client that dates are taken or available. The reason for the this setup is I have a rates table with a days_rates join Thanks DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 08-14-2010 [eluser]OverZealous[/eluser] [quote author="kre8ivdesigns" date="1281857684"] Now how do I check if the day_id exists in the join table days_reservation to return to the client that dates are taken or available.[/quote] Once you have the day, simply do: Code: if($day->reservation->count()) { This returns the number of reservations for a given day. As long as that can only be 0 or 1, this will work. If you need to limit the reservations (ie: there can be more thab one reservation per day), simply add clauses into your statement: Code: $day->reservation->where(<<whatever>>)->count(); DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 08-14-2010 [eluser]kre8ivdesigns[/eluser] Fatal error: Class name must be a valid object or a string in D:\xampp\htdocs\test.com\application\libraries\datamapper.php on line 2418 And here are my models Code: <?php Code: class Day extends DataMapper { DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 08-14-2010 [eluser]kre8ivdesigns[/eluser] Ok i tried that and it doesnt work... Thanks so far. The goal A client enters a checkin and checkout date The dates they enter are populated into an date array to do a day by day check to the days table If there is a match it returns the id from the days table What I need to do is to see if the id from the days table is present in the days_reservations joined table and if it is that means the date is already booked. Sorry for the trouble.. T DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 08-14-2010 [eluser]kre8ivdesigns[/eluser] Here is the code Code: function check_dates($checkin,$checkout) |