public function loadFromRow(array $row)
    {
        if (empty($row)) {
            throw new InvalidArgumentException('Database row expected');
        }

        $this->startLoading();

        $found_generated_fields = [];

        foreach ($row as $k => $v) {
            if ($this->isGeneratedField($k)) {
                $found_generated_fields[] = $k;
            } elseif ($this->fieldExists($k)) {
                $this->setFieldValue($k, $v);
            }
        }

        if (!empty($found_generated_fields)) {
            $generated_field_values = [];

            $value_caster = $this->getGeneratedFieldsValueCaster();

            if ($value_caster instanceof ValueCasterInterface) {
                $generated_field_values = array_intersect_key($row, array_flip($found_generated_fields));

                $value_caster->castRowValues($generated_field_values);
            }

            foreach ($generated_field_values as $k => $v) {
                $this->setFieldValue($k, $v);
            }
        }

        $this->doneLoading();
    }
public function loadFromRow(array $row)
    {
        if (empty($row)) {
            throw new InvalidArgumentException('Database row expected');
        }

        $this->startLoading();

        $found_generated_fields = [];

        foreach ($row as $k => $v) {
            if ($this->isGeneratedField($k)) {
                $found_generated_fields[] = $k;
            } elseif ($this->fieldExists($k)) {
                $this->setFieldValue($k, $v);
            }
        }

        if (!empty($found_generated_fields)) {
            $generated_field_values = [];

            $value_caster = $this->getGeneratedFieldsValueCaster();

            if ($value_caster instanceof ValueCasterInterface) {
                $generated_field_values = array_intersect_key($row, array_flip($found_generated_fields));

                $value_caster->castRowValues($generated_field_values);
            }

            foreach ($generated_field_values as $k => $v) {
                $this->setFieldValue($k, $v);
            }
        }

        $this->doneLoading();
    }
public function loadFromRow ( array $ row ) { if ( empty ( $ row ) ) { throw new InvalidArgumentException ( 'Database row expected' ) ; } $ this -> startLoading ( ) ; $ found_generated_fields = [ ] ; foreach ( $ row as $ k => $ v ) { if ( $ this -> isGeneratedField ( $ k ) ) { $ found_generated_fields [ ] = $ k ; } elseif ( $ this -> fieldExists ( $ k ) ) { $ this -> setFieldValue ( $ k , $ v ) ; } } if ( ! empty ( $ found_generated_fields ) ) { $ generated_field_values = [ ] ; $ value_caster = $ this -> getGeneratedFieldsValueCaster ( ) ; if ( $ value_caster instanceof ValueCasterInterface ) { $ generated_field_values = array_intersect_key ( $ row , array_flip ( $ found_generated_fields ) ) ; $ value_caster -> castRowValues ( $ generated_field_values ) ; } foreach ( $ generated_field_values as $ k => $ v ) { $ this -> setFieldValue ( $ k , $ v ) ; } } $ this -> doneLoading ( ) ; }
Load data from database row.

If $cache_row is set to true row data will be added to cache

@param  array                    $row
@throws InvalidArgumentException
Load data from database row .