[Solar-svn] Revision 2776

pmjones at solarphp.com pmjones at solarphp.com
Sun Sep 23 16:26:33 CDT 2007


branch: Solar_Sql_Model: [FIX] Method update() no longer lets you reset the primary key when the data is an array.



Modified: branches/orm/Solar/Sql/Model.php
===================================================================
--- branches/orm/Solar/Sql/Model.php	2007-09-23 21:24:20 UTC (rev 2775)
+++ branches/orm/Solar/Sql/Model.php	2007-09-23 21:26:32 UTC (rev 2776)
@@ -1765,22 +1765,23 @@
         /**
          * Record filtering and WHERE clause
          */
+        
+        // what's the primary key?
+        $primary = $this->_primary_col;
         if ($spec instanceof Solar_Sql_Model_Record) {
-            // apply record filters and convert to array
+            // apply record filters and convert to array, then force the
+            // WHERE clause
             $spec->filter();
             $data = $spec->toArray();
-            
-            // force the WHERE clause
-            $primary = $this->_primary_col;
             $where = array("$primary = ?" => $data[$primary]);
-            
-            // don't update the primary key
-            unset($data[$primary]);
         } else {
             // already an array
             $data = $spec;
         }
         
+        // don't update the primary key
+        unset($data[$primary]);
+        
         /**
          * Final prep, then update
          */




More information about the Solar-svn mailing list