tags:

views:

19

answers:

0

I have a PHP script that uses PEAR to access and update a MySQL table (below). The table has 2 primary key pair: code_class & code_value. I'm trying to update a table record with a code_value of "APP" to "APPL". A relatively simple task, right? But with PEAR, it seems like the primary key is throwing a wrench into task and rather than using the new value to update the record, PEAR is trying to use the value in the where clause.

TABLE

Field         Type
code_class  varchar         PRI          
code_value  varchar         PRI          
code_value_desc     varchar
rank    int
modify_dt   timestamp
create_dt   datetime
active  enum

PHP

        $cv = DB_DataObject::factory('code_value');
        $cv->code_class = $codeClass;
        $cv->code_value = $codeValue;
        $cv->find();

        if ($cv->fetch()) {
            $cv->code_class = $_REQUEST['Class'];
            $cv->code_value = $_REQUEST['Code'];
            $cv->code_value_desc = $_REQUEST['Description'];
            $cv->active = $_REQUEST['Active'];
            $cv->update();
        }

PEAR SQL

DataObjects_Code_value: QUERY: UPDATE code_value SET code_value_desc = 'Application' , rank = 24 , create_dt = '2010-05-11 23:28:52' , active = 'Yes' WHERE code_value.code_class = 'IMAGE_TY' AND code_value.code_value = 'APPL' 

DESIRED SQL

DataObjects_Code_value: QUERY: UPDATE code_value SET code_value.code_class = 'IMAGE_TY' , code_value.code_value = 'APPL' , code_value_desc = 'Application' , rank = 24 , create_dt = '2010-05-11 23:28:52' , active = 'Yes' WHERE code_value.code_class = 'IMAGE_TY' AND code_value.code_value = 'APP' 

Is it possible to get PEAR to make this update happen or do I just need to use a customer SQL statement? I've tried to change the table structure to UNIQUE type index and update my PEAR DataOject file but it didn't seem to change anything.

Has anyone else experienced the same issue? If so, what did you do to resolve it?