Closed iluwatar closed 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
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.
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.
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.
I would be interested to hear how you would implement this before taking it further.
By the way, I forgot to add that changes would be completely backward compatible!
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.