Welcome Guest, Not a member yet? Register   Sign In
Datamapper ORM Multi-tabel Relationship Halp!
#5

[eluser]Genki1[/eluser]
Okay, I get it that multi-relationships are not supported and I'm thinking about your answer. However, your answer changed my scenario and I want to make sure I implement it correctly (to avoid banging my head on the table for another 5 hours :-) )

What I want is this: (item in red is an edit to your answer, above)
Quote:User -> has many -> Purchases
Templates -> has many -> Purchases
Options -> has many -> Purchases
Purchases -> has one -> User
Purchases -> has one -> Template
Purchases -> has many -> Options

So, will this work...

Code:
$user = new User(1);

// get all this user's purchases
$user->purchase->get();

// get info about a specific purchase
$user->purchase->where('template_id', 16)->get();

// get all options for this purchase
$purchase = new Purchase(3);
$purchase->option->get();


...using this table?

join_table: "purchases"

Code:
[id] [user_id] [template_id] [option_id] [value_for_this_template_option]
  1       1         1             1        Some data
  2       1         1             3        more stuff
  3       1         2             1        Maybe my name here
  4       1         2             5        contact info
  5       2         1             1        Yet more user data


Messages In This Thread
Datamapper ORM Multi-tabel Relationship Halp! - by El Forum - 07-27-2011, 12:34 PM
Datamapper ORM Multi-tabel Relationship Halp! - by El Forum - 07-28-2011, 02:04 AM
Datamapper ORM Multi-tabel Relationship Halp! - by El Forum - 08-04-2011, 07:18 PM
Datamapper ORM Multi-tabel Relationship Halp! - by El Forum - 08-05-2011, 04:49 AM
Datamapper ORM Multi-tabel Relationship Halp! - by El Forum - 08-05-2011, 08:54 AM
Datamapper ORM Multi-tabel Relationship Halp! - by El Forum - 08-05-2011, 11:37 AM
Datamapper ORM Multi-tabel Relationship Halp! - by El Forum - 08-06-2011, 03:44 AM
Datamapper ORM Multi-tabel Relationship Halp! - by El Forum - 08-06-2011, 04:01 AM
Datamapper ORM Multi-tabel Relationship Halp! - by El Forum - 08-06-2011, 01:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB