public function hydrate($data, $strictLoad = true)
    {
        // using reflection to check if property exist
        $reflection = new \ReflectionObject($this);
        foreach ($data as $k => $v) {
            // if strictLoad is disabled, all properties are allowed to be hydrated
            if (!$strictLoad) {
                $this->{$k} = $v;
                continue;
            }
            // check if property really exists in class
            if ($reflection->hasProperty($k)) {
                $this->{$k} = $v;
                continue;
            }
            // test relation auto get fields
            foreach (static::$_relations as $uneRelation) {
                // check if this field is in auto get from relation
                if ($uneRelation['typeRelation'] == self::ONE_TO_ONE && in_array($k, $uneRelation['autoGetFields'])) {
                    $this->{$k} = $v;
                    break;
                }
            }
        }

        // model is not new anymore
        $this->_isNew = false;
    }
public function hydrate($data, $strictLoad = true)
    {
        // using reflection to check if property exist
        $reflection = new \ReflectionObject($this);
        foreach ($data as $k => $v) {
            // if strictLoad is disabled, all properties are allowed to be hydrated
            if (!$strictLoad) {
                $this->{$k} = $v;
                continue;
            }
            // check if property really exists in class
            if ($reflection->hasProperty($k)) {
                $this->{$k} = $v;
                continue;
            }
            // test relation auto get fields
            foreach (static::$_relations as $uneRelation) {
                // check if this field is in auto get from relation
                if ($uneRelation['typeRelation'] == self::ONE_TO_ONE && in_array($k, $uneRelation['autoGetFields'])) {
                    $this->{$k} = $v;
                    break;
                }
            }
        }

        // model is not new anymore
        $this->_isNew = false;
    }
public function hydrate ( $ data , $ strictLoad = true ) { // using reflection to check if property exist $ reflection = new \ ReflectionObject ( $ this ) ; foreach ( $ data as $ k => $ v ) { // if strictLoad is disabled, all properties are allowed to be hydrated if ( ! $ strictLoad ) { $ this -> { $ k } = $ v ; continue ; } // check if property really exists in class if ( $ reflection -> hasProperty ( $ k ) ) { $ this -> { $ k } = $ v ; continue ; } // test relation auto get fields foreach ( static :: $ _relations as $ uneRelation ) { // check if this field is in auto get from relation if ( $ uneRelation [ 'typeRelation' ] == self :: ONE_TO_ONE && in_array ( $ k , $ uneRelation [ 'autoGetFields' ] ) ) { $ this -> { $ k } = $ v ; break ; } } } // model is not new anymore $ this -> _isNew = false ; }
Hydrate model from a fetch assoc
including OneToOne relation auto get field

@param $data
@param $strictLoad - if true, all fields from $data will be loaded
Hydrate model from a fetch assoc including OneToOne relation auto get field