예제 #1
0
파일: Params.php 프로젝트: btweedy/foresmo
 /**
  * 
  * Loads this params object with an array or struct.
  * 
  * @param array|Solar_Struct $spec The data to load.
  * 
  * @return Solar_Sql_Model_Params
  * 
  * @see _load()
  * 
  */
 public function load($spec)
 {
     parent::load($spec);
     return $this;
 }
예제 #2
0
파일: Record.php 프로젝트: btweedy/foresmo
 /**
  * 
  * Initialize the record object.  This is effectively a "first load"
  * method.
  * 
  * @param Solar_Sql_Model $model The originating model object instance (a
  * dependency injection).
  * 
  * @param array $spec The data with which to initialize this record.
  * 
  * @return void
  * 
  */
 public function init(Solar_Sql_Model $model, $spec)
 {
     if ($this->_model) {
         throw $this->_exception('ERR_CANNOT_RE_INIT');
     }
     // inject the model
     $this->_model = $model;
     // sets access methods
     $this->_setAccessMethods();
     // force spec to array
     if ($spec instanceof Solar_Struct) {
         // we can do this because $spec is of the same class
         $load = $spec->_data;
     } elseif (is_array($spec)) {
         $load = $spec;
     } else {
         $load = array();
     }
     // unserialize any serialize_cols in the load
     $this->_model->unserializeCols($load);
     // Make sure changes to xml struct records cause us to be dirty
     foreach ($this->_model->xmlstruct_cols as $col) {
         if (!empty($load[$col])) {
             $load[$col]->setParent($this);
         }
     }
     // use parent load to push values directly into $_data array
     parent::load($load);
     // Record the inital values but only for columns that have physical backing
     $this->_initial = array_intersect_key($load, $model->table_cols);
     // placeholders for nonexistent calculate_cols, bypassing __set
     foreach ($this->_model->calculate_cols as $name => $info) {
         if (!array_key_exists($name, $this->_data)) {
             $this->_data[$name] = null;
         }
     }
     // fix up related data elements
     $this->_fixRelatedData();
     // new?
     $this->_is_new = false;
     // can't be invalid
     $this->_invalid = array();
     // can't be dirty
     $this->_is_dirty = false;
     // no last sql status
     $this->_sql_status = null;
 }