[Solar-svn] Revision 2697
pmjones at solarphp.com
pmjones at solarphp.com
Tue Aug 14 08:06:10 CDT 2007
Branch: Solar_Sql_Model_Record: [CHG] Override parent method load() to automatically unserialize columns per the model property "serialize_cols".
Modified: branches/orm/Solar/Sql/Model/Record.php
===================================================================
--- branches/orm/Solar/Sql/Model/Record.php 2007-08-14 13:04:09 UTC (rev 2696)
+++ branches/orm/Solar/Sql/Model/Record.php 2007-08-14 13:06:10 UTC (rev 2697)
@@ -235,6 +235,34 @@
return $result;
}
+ /**
+ *
+ * Loads the struct with data from an array or another struct.
+ *
+ * Also unserializes columns per the "serialize_cols" model property.
+ *
+ * @param array|Solar_Struct $spec The data to load into the object.
+ *
+ * @return void
+ *
+ */
+ public function load($spec)
+ {
+ parent::load($spec);
+
+ // unseralize columns as-needed
+ foreach ($this->_model->serialize_cols as $key) {
+ // only unserialize if a non-empty string
+ if (! empty($this->_data[$key]) && is_string($this->_data[$key])) {
+ $this->_data[$key] = unserialize($this->_data[$key]);
+ if (! $this->_data[$key]) {
+ // unserializing failed
+ $this->_data[$key] = null;
+ }
+ }
+ }
+ }
+
// -----------------------------------------------------------------
//
// Model
More information about the Solar-svn
mailing list