DB_DataObject and multiple column primary keys

From: Date: Wed, 02 Feb 2005 18:32:42 +0000
Subject: DB_DataObject and multiple column primary keys
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17339@lists.php.net to get a copy of this message
Hi, I have the following MySQL table : create table facture (
    status enum ('pending','validated') not null,
    id int not null auto_increment,
    currency char (3) not null,
    is_index_synced bit not null,
    primary key (status,id),
); As you can see, the primary key is made of several columns : status and id. That means, for example that there can be two rows with an id of 123, given that one has a status of 'pending' and the other a status of 'validated'. The id field is auto-incrementing. MySQL handles all of that pretty smartly. I've been thinking a lot about the application design, and using a single column primary key is much less handy. DB_DataObject does not seem to be able to support such keys. Until now I've been pretty successful hacking around the problem, but with the update() method it becomes quite dangerous, since DB_DO will perform : UPDATE facture SET ... WHERE id = 123; when it should be : UPDATE facture SET ... WHERE id = 123 and status = 'pending'; Of course, I'm about to overload update(), but I feel like there may be some situation where my tables could get corrupted. Is there any plan to support multiple columns indexes ? ref : http://dev.mysql.com/doc/mysql/en/multiple-column-indexes.html -- og

« previous php.pear.general (#17339) next »