src/Mmi/Orm/RecordRo.php
public function setFromArray(array $row = [])
    {
        $joinedRows = [];
        foreach ($row as $key => $value) {
            //przyjęcie pól z joinów
            if (false !== strpos($key, '__')) {
                $keyParts = explode('__', $key);
                $joinedRows[$keyParts[0]][$keyParts[1]][$keyParts[2]] = $value;
                continue;
            }
            $field = \Mmi\Orm\Convert::underscoreToCamelcase($key);
            if (property_exists($this, $field)) {
                $this->$field = $value;
                continue;
            }
            $this->setOption($field, $value);
        }
        //podpięcie joinów pod główny rekord
        foreach ($joinedRows as $alias => $tables) {
            foreach ($tables as $tableName => $fields) {
                $recordClass = \Mmi\Orm\DbConnector::getRecordNameByTable($tableName);
                $record = new $recordClass;
                $record->setFromArray($fields)
                    ->clearModified();
                $this->_joined[$alias] = $record;
            }
        }
        //wypełniony
        $this->_filled = true;
        return $this;
    }
public function setFromArray(array $row = [])
    {
        $joinedRows = [];
        foreach ($row as $key => $value) {
            //przyjęcie pól z joinów
            if (false !== strpos($key, '__')) {
                $keyParts = explode('__', $key);
                $joinedRows[$keyParts[0]][$keyParts[1]][$keyParts[2]] = $value;
                continue;
            }
            $field = \Mmi\Orm\Convert::underscoreToCamelcase($key);
            if (property_exists($this, $field)) {
                $this->$field = $value;
                continue;
            }
            $this->setOption($field, $value);
        }
        //podpięcie joinów pod główny rekord
        foreach ($joinedRows as $alias => $tables) {
            foreach ($tables as $tableName => $fields) {
                $recordClass = \Mmi\Orm\DbConnector::getRecordNameByTable($tableName);
                $record = new $recordClass;
                $record->setFromArray($fields)
                    ->clearModified();
                $this->_joined[$alias] = $record;
            }
        }
        //wypełniony
        $this->_filled = true;
        return $this;
    }
public function setFromArray ( array $ row = [ ] ) { $ joinedRows = [ ] ; foreach ( $ row as $ key => $ value ) { //przyjęcie pól z joinów if ( false !== strpos ( $ key , '__' ) ) { $ keyParts = explode ( '__' , $ key ) ; $ joinedRows [ $ keyParts [ 0 ] ] [ $ keyParts [ 1 ] ] [ $ keyParts [ 2 ] ] = $ value ; continue ; } $ field = \ Mmi \ Orm \ Convert :: underscoreToCamelcase ( $ key ) ; if ( property_exists ( $ this , $ field ) ) { $ this -> $ field = $ value ; continue ; } $ this -> setOption ( $ field , $ value ) ; } //podpięcie joinów pod główny rekord foreach ( $ joinedRows as $ alias => $ tables ) { foreach ( $ tables as $ tableName => $ fields ) { $ recordClass = \ Mmi \ Orm \ DbConnector :: getRecordNameByTable ( $ tableName ) ; $ record = new $ recordClass ; $ record -> setFromArray ( $ fields ) -> clearModified ( ) ; $ this -> _joined [ $ alias ] = $ record ; } } //wypełniony $ this -> _filled = true ; return $ this ; }
Ustawia dane w obiekcie na podstawie tabeli
@param array $row tabela z danymi
@param bool $fromDb czy z bazy danych
@return \Mmi\Orm\Record
Ustawia dane w obiekcie na podstawie tabeli