system/classes/Model.php
protected function _populateAttributes($record)
    {
      foreach ($this->model_attributes as $key => $def) {

        // If the data is present in the DB, assign to model.
        // Otherwise ignore any data returned from the DB that isn't defined in the model.
        if (isset($record[$this->getFieldName($key)])) {
          $fieldName = $this->getFieldName($key);
          
          if (\Cora\Gateway::is_serialized($record[$fieldName])) {
            $value = unserialize($record[$fieldName]);
          }
          else if (isset($def['type']) && ($def['type'] == 'date' || $def['type'] == 'datetime')) {
            $value = new \DateTime($record[$fieldName]);
          }
          else {
            $value = $record[$fieldName];
          }
          $this->beforeSet($key, $value); // Lifecycle callback
          $this->model_data[$key] = $value;
          $this->afterSet($key, $value); // Lifecycle callback
        }
        else if (isset($def['models']) || (isset($def['model']) && isset($def['usesRefTable']))) {
          if (!isset($this->model_data[$key])) $this->model_data[$key] = 1;
        }
      }
    }
protected function _populateAttributes($record)
    {
      foreach ($this->model_attributes as $key => $def) {

        // If the data is present in the DB, assign to model.
        // Otherwise ignore any data returned from the DB that isn't defined in the model.
        if (isset($record[$this->getFieldName($key)])) {
          $fieldName = $this->getFieldName($key);
          
          if (\Cora\Gateway::is_serialized($record[$fieldName])) {
            $value = unserialize($record[$fieldName]);
          }
          else if (isset($def['type']) && ($def['type'] == 'date' || $def['type'] == 'datetime')) {
            $value = new \DateTime($record[$fieldName]);
          }
          else {
            $value = $record[$fieldName];
          }
          $this->beforeSet($key, $value); // Lifecycle callback
          $this->model_data[$key] = $value;
          $this->afterSet($key, $value); // Lifecycle callback
        }
        else if (isset($def['models']) || (isset($def['model']) && isset($def['usesRefTable']))) {
          if (!isset($this->model_data[$key])) $this->model_data[$key] = 1;
        }
      }
    }
For handling data which is defined as being on this model.

@param array $record An associative array (like a row of data from a database).
@return void