DB_DataObject, UNIQUE-keys and update-method
| From: | Jari-Pekka Arvo | Date: | Thu, 08 Jul 2004 13:40:18 +0000 |
| Subject: | DB_DataObject, UNIQUE-keys and update-method | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-13550@lists.php.net to get a copy of this message | ||
Hi,
I noticed that DB_DataObjects update()-method can't be used to update columns that are part of a key declared as UNIQUE. In my case I wanted to update a table which have a primary key and a unique-key consisting of tree columns. What happened was that nothing got updated, no error raised and when I checked debug output I found out that the method uses UNIQUE-constraints in WHERE-clause and didn't even try to update the fields I wanted.
I know I can use $do->query() -method (did it already) and I know I can manually edit the 'foo.ini'-file (not recommended) but I think this is a design flaw in DB_DataObject-package. UNIQUE -keys are a good way to make sure the data in a single relation keeps its coherency, they are not (usually) used to referring table in joins. What if someone makes a typo when inserting data in a field that just happens to be a part of a unique key? Should the mistake be irreparable (as in my opinion this design conception suggests)?
To put it shortly: I think that primary keys and unique-keys differ in semantics so much, that they should be treated separately in DO-code. Why not just left them out of any key-definitions (in PHP-code)?
---
J-P Arvo