protected function load($resultArray, $sanitizeArray = FALSE) {
    if (!is_array($resultArray)) {
      $resultArray = json_decode($resultArray, TRUE);
      if (!is_array($resultArray)) {
        throw new InvalidJSONException("Invalid JSON used to load a model");
      }
    }

    if (!empty($resultArray[$this->idColumn])) {
      if (!$sanitizeArray) {
        $dataConnection = $this->app->getDataConnection($this->connection);
        $this->{$this->idProperty} = $dataConnection->convertFromNativeId($resultArray[$this->idColumn]);
      }
      unset($resultArray[$this->idColumn]);
      unset($resultArray[$this->idProperty]);
    }

    foreach ($this->modelFieldsInfo as $modelFieldInfo) {
      if (!array_key_exists($modelFieldInfo->name, $resultArray)) {
        continue;
      }

      // Ignores setting any model property with 'internal' or 'system' options if sanitizing the input
      if ($sanitizeArray && ($modelFieldInfo->isInternal || $modelFieldInfo->isSystem)) {
        unset($resultArray[$modelFieldInfo->name]);
        continue;
      }

      // Pulls out the type following the pattern @var <TYPE> from the doc comments of the property
      if (!$modelFieldInfo->hasType) {
        $this->{$modelFieldInfo->name} = $resultArray[$modelFieldInfo->name];
      }
      else {
        if ($modelFieldInfo->isArrayType) {
          // If the type follows the list of type pattern (<TYPE>[]), an array will be generated and filled
          // with that type
          $outArr = array();
          if (!empty($resultArray[$modelFieldInfo->name])) {
            foreach ($resultArray[$modelFieldInfo->name] as $listResult) {
              $this->loadField($modelFieldInfo, $parameter, $listResult);
              $outArr[] = $parameter;
            }
          }
          $this->{$modelFieldInfo->name} = $outArr;
        }
        else {
          $this->loadField($modelFieldInfo, $this->{$modelFieldInfo->name}, $resultArray[$modelFieldInfo->name]);
        }
      }
      unset($resultArray[$modelFieldInfo->name]);
    }

    $this->_remainingReadResults = $resultArray;
  }
protected function load($resultArray, $sanitizeArray = FALSE) {
    if (!is_array($resultArray)) {
      $resultArray = json_decode($resultArray, TRUE);
      if (!is_array($resultArray)) {
        throw new InvalidJSONException("Invalid JSON used to load a model");
      }
    }

    if (!empty($resultArray[$this->idColumn])) {
      if (!$sanitizeArray) {
        $dataConnection = $this->app->getDataConnection($this->connection);
        $this->{$this->idProperty} = $dataConnection->convertFromNativeId($resultArray[$this->idColumn]);
      }
      unset($resultArray[$this->idColumn]);
      unset($resultArray[$this->idProperty]);
    }

    foreach ($this->modelFieldsInfo as $modelFieldInfo) {
      if (!array_key_exists($modelFieldInfo->name, $resultArray)) {
        continue;
      }

      // Ignores setting any model property with 'internal' or 'system' options if sanitizing the input
      if ($sanitizeArray && ($modelFieldInfo->isInternal || $modelFieldInfo->isSystem)) {
        unset($resultArray[$modelFieldInfo->name]);
        continue;
      }

      // Pulls out the type following the pattern @var <TYPE> from the doc comments of the property
      if (!$modelFieldInfo->hasType) {
        $this->{$modelFieldInfo->name} = $resultArray[$modelFieldInfo->name];
      }
      else {
        if ($modelFieldInfo->isArrayType) {
          // If the type follows the list of type pattern (<TYPE>[]), an array will be generated and filled
          // with that type
          $outArr = array();
          if (!empty($resultArray[$modelFieldInfo->name])) {
            foreach ($resultArray[$modelFieldInfo->name] as $listResult) {
              $this->loadField($modelFieldInfo, $parameter, $listResult);
              $outArr[] = $parameter;
            }
          }
          $this->{$modelFieldInfo->name} = $outArr;
        }
        else {
          $this->loadField($modelFieldInfo, $this->{$modelFieldInfo->name}, $resultArray[$modelFieldInfo->name]);
        }
      }
      unset($resultArray[$modelFieldInfo->name]);
    }

    $this->_remainingReadResults = $resultArray;
  }
protected function load ( $ resultArray , $ sanitizeArray = FALSE ) { if ( ! is_array ( $ resultArray ) ) { $ resultArray = json_decode ( $ resultArray , TRUE ) ; if ( ! is_array ( $ resultArray ) ) { throw new InvalidJSONException ( "Invalid JSON used to load a model" ) ; } } if ( ! empty ( $ resultArray [ $ this -> idColumn ] ) ) { if ( ! $ sanitizeArray ) { $ dataConnection = $ this -> app -> getDataConnection ( $ this -> connection ) ; $ this -> { $ this -> idProperty } = $ dataConnection -> convertFromNativeId ( $ resultArray [ $ this -> idColumn ] ) ; } unset ( $ resultArray [ $ this -> idColumn ] ) ; unset ( $ resultArray [ $ this -> idProperty ] ) ; } foreach ( $ this -> modelFieldsInfo as $ modelFieldInfo ) { if ( ! array_key_exists ( $ modelFieldInfo -> name , $ resultArray ) ) { continue ; } // Ignores setting any model property with 'internal' or 'system' options if sanitizing the input if ( $ sanitizeArray && ( $ modelFieldInfo -> isInternal || $ modelFieldInfo -> isSystem ) ) { unset ( $ resultArray [ $ modelFieldInfo -> name ] ) ; continue ; } // Pulls out the type following the pattern @var <TYPE> from the doc comments of the property if ( ! $ modelFieldInfo -> hasType ) { $ this -> { $ modelFieldInfo -> name } = $ resultArray [ $ modelFieldInfo -> name ] ; } else { if ( $ modelFieldInfo -> isArrayType ) { // If the type follows the list of type pattern (<TYPE>[]), an array will be generated and filled // with that type $ outArr = array ( ) ; if ( ! empty ( $ resultArray [ $ modelFieldInfo -> name ] ) ) { foreach ( $ resultArray [ $ modelFieldInfo -> name ] as $ listResult ) { $ this -> loadField ( $ modelFieldInfo , $ parameter , $ listResult ) ; $ outArr [ ] = $ parameter ; } } $ this -> { $ modelFieldInfo -> name } = $ outArr ; } else { $ this -> loadField ( $ modelFieldInfo , $ this -> { $ modelFieldInfo -> name } , $ resultArray [ $ modelFieldInfo -> name ] ) ; } } unset ( $ resultArray [ $ modelFieldInfo -> name ] ) ; } $ this -> _remainingReadResults = $ resultArray ; }
Loads the data for the model from a PHP array or a json string into the current model object using reflection
and MABI annotations.

@param $resultArray array|string Either an associative array that maps to the model or a JSON string which can be turned into one
@param $sanitizeArray bool Whether to clean up $resultArray

@throws InvalidJSONException
Loads the data for the model from a PHP array or a json string into the current model object using reflection and MABI annotations .