![]() |
Datamapper ORM Join Help! - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Datamapper ORM Join Help! (/showthread.php?tid=46968) |
Datamapper ORM Join Help! - El Forum - 11-22-2011 [eluser]jordanarseno[/eluser] I need help constructing a Datamapper ORM query that includes join fields. I have a table of Merchants and a table of Vendors. They have a many-to-one relationship, that is, many Merchants are part of a single Vendor. Thus, my datebase tables, following the Datamapper ORM convention are: merchants vendors merchants_vendors Furthermore, in the merchants_vendors table, I have join fields 'role' and 'admin'. Obviously, this data must be placed in the join table, if it were placed in the Merchants table, I wouldn't be able to define roles and administrators per Vendor. Lastly, Merchants are related to Users by a one-to-one relationship. Think of Merchants as just an extension of Users. I'm attempting to create a PHP array from the data that follows this data structure, but I can't seem to get the role and admin fields populating properly. I removed redundant columns for your simplicity: Code: [vendor] => Array Here's the code I'm using - Assuming we know the Vendor ID: Code: $v = new Vendor($id); This gets me as far as the above PHP data structure without the role and admin. I am well aware of the include_join_fields() function - but I cannot seem to get it working. Specifically, I tried Code: $m->vendor->include_join_fields(); Code: $mV->vendor->join_role Code: $mV->vendor->join_admin Your help is much appreciated - I also posted this question on StackOverflow, if you wish to get some cred over there too! |