j4mie / idiorm

A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5.
http://j4mie.github.com/idiormandparis/
2.01k stars 369 forks source link

compound primary keys #14

Closed iluwatar closed 13 years ago

iluwatar commented 13 years ago

Is there some way to make idiorm save() work with tables with compound primary keys? The configuration allows only single column to be specified as primary key.

j4mie commented 13 years ago

Hi,

Unfortunately, one of Idiorm's core assumptions is that each table will have a single primary key column. Although this is a limitation, it is quite common in many DB abstraction layers. As Idiorm is deliberately simple, this feature isn't high on my list of priorities.

Off the top of my head, Zend DB supports compound keys as does Doctrine 2.

Cheers

Jamie

iluwatar commented 13 years ago

Thanks. I think I'll stick with idiorm anyway. Do you have a recommendation how to go around the limitation? I was thinking of executing queries manually through ORM::get_db()->exec when I need to do update/insert/delete in tables with compound primary keys.

j4mie commented 13 years ago

You could take that approach, or (I think) you could use

ORM::for_table('your_table')->raw_query('your query here')->find_one();

But that is a bit of a hack! Your approach is probably better.

kendru commented 11 years ago

I think that composite key support would be helpful, especially if Paris also supported tables with composite primary keys. In my latest application using Idiorm, I have to drop down to PDO to update my join tables. I would be willing to tackle this feature if it fits with the goal of Idiorm.

treffynnon commented 11 years ago

I would be interested to hear how you would implement this before taking it further.

lrlopez commented 11 years ago

By the way, I forgot to add that changes would be completely backward compatible!