CodeIgniter Forums

Full Version: DataMapper ORM composite key handling
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

Essentially, I have a sales_orders table that has as its primary key the column names (account_id, acct_order_number). I need to have this because the acct_order_number may be the same from two different accounts. I then have a sales_order_items table that references the sales_orders table using the same two column names as the foreign key. What is the best practice for this with DataMapper ORM?

I currently have a sales_order_id column in my sales_order_items table (in addition to the foreign key fields) and I then run an update query that populates the sales_order_id based on records that match the foreign key fields in the sales_order table (for records where the sales_order_id field is null). These update queries take quite a long time; I am only doing this so that I can use the "simple" DataMapper key/relationship features. Ideally, I would like to map the foreign composite key directly to the related table.

Thank you for any help.

p.s. DataMapper ORM is awesome so far (I've only been using it a few days)!