Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I recently found out about Class::DBI and I'm loving it.
While attempting to represent a Many-To-Many relationship (for my shopping cart) I ran into a problem:
my table has 2 fields (user_id and item_id), I can add a relationship by using find_or_create({user_id => 1, item_id => 2}) however if I try to delete a relationship I run into lots of trouble.
Since user_id is taken as the "Primary" key if I Cart->delete(user_id => 1, item_id => 2) all relationships containing user_id = 1 are deleted (I want only the one with item_id = 2 to go away). I thought of creating a junk field in the DB and labeling it as the primary key but that is a waste of a field that will never actually be used. I also tried using Class::DBI::Join but it is broken and not maintained.
Please suggest a module or method to get around this, thanks in advance!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Many-to-many with Class::DBI
by jgallagher (Pilgrim) on May 12, 2003 at 01:05 UTC | |
|
Re: Many-to-many with Class::DBI
by edoc (Chaplain) on May 12, 2003 at 00:59 UTC | |
|
Re: Many-to-many with Class::DBI
by Ovid (Cardinal) on May 12, 2003 at 03:03 UTC | |
by edoc (Chaplain) on May 12, 2003 at 03:18 UTC | |
|
Re: Many-to-many with Class::DBI
by jeffa (Bishop) on Aug 10, 2003 at 21:40 UTC |