[Solar-svn] Revision 2775

pmjones at solarphp.com pmjones at solarphp.com
Sun Sep 23 16:24:20 CDT 2007


branch: Solar_Sql_Model_Record: [FIX] Magic methods now properly fall back to the parent magic methods.



Modified: branches/orm/Solar/Sql/Model/Record.php
===================================================================
--- branches/orm/Solar/Sql/Model/Record.php	2007-09-23 20:25:17 UTC (rev 2774)
+++ branches/orm/Solar/Sql/Model/Record.php	2007-09-23 21:24:20 UTC (rev 2775)
@@ -133,12 +133,14 @@
         // default value
         $result = null;
         
-        // if an accessor method exists, use it to return the data
+        // if an accessor method exists, use it
         if (! empty($this->_access_methods['get'][$key])) {
+            // use accessor method
             $method = $this->_access_methods['get'][$key];
             return $this->$method();
         } else {
-            return $this->_data[$key];
+            // no accessor method; use parent method.
+            return parent::__get($key);
         }
     }
     
@@ -164,14 +166,14 @@
             $this->_status = 'dirty';
         }
         
-        // how to set the value?
+        // if an accessor method exists, use it
         if (! empty($this->_access_methods['set'][$key])) {
             // use accessor method
             $method = $this->_access_methods['set'][$key];
             $this->$method($val);
         } else {
-            // no accessor method, not a primary key; assign directly.
-            $this->_data[$key] = $val;
+            // no accessor method; use parent method
+            parent::__set($key, $val);
         }
     }
     
@@ -189,14 +191,14 @@
         // disallow if status is 'deleted'
         $this->_checkDeleted();
         
-        // how to unset the value?
+        // if an accessor method exists, use it
         if (! empty($this->_access_methods['unset'][$key])) {
             // use accessor method
             $method = $this->_access_methods['unset'][$key];
             $this->$method();
         } else {
-            // no accessor method
-            unset($this->_data[$key]);
+            // no accessor method; use parent method
+            parent::__unset($key);
         }
     }
     
@@ -214,14 +216,14 @@
         // disallow if status is 'deleted'
         $this->_checkDeleted();
         
-        // how to check the value?
+        // if an accessor method exists, use it
         if (! empty($this->_access_methods['isset'][$key])) {
             // use accessor method
             $method = $this->_access_methods['isset'][$key];
             $result = $this->$method();
         } else {
-            // no accessor method
-            $result = isset($this->_data[$key]);
+            // no accessor method; use parent method
+            $result = parent::__isset($key);
         }
         
         // done




More information about the Solar-svn mailing list