src/Result.php
final private function parseFetched(array $row, FetchMode $fetchmode) {
        foreach($row as $tag => $value) {
            if(isset($this->parameters[$tag])) {
                $param =& $this->parameters[$tag]['param'];
                $type = $this->parameters[$tag]['type'];
                $param = $this->connection->quote($value, $type);
            }
        }
        if($fetchmode->hasMode(DB::FETCH_BOTH)) return array_merge ($row, array_values ($row));
        if($fetchmode->hasMode(DB::FETCH_ASSOC)) return $row;
        if($fetchmode->hasMode(DB::FETCH_NUM)) return array_values ($row);
        if($fetchmode->hasMode(DB::FETCH_COLUMN)) {
            $values = array_values($row);
            return isset($values[$fetchmode->col]) ? $values[$fetchmode->col] : null;
        }
        if($fetchmode->hasMode(DB::FETCH_OBJ)) return (object)$row;
        if($fetchmode->hasMode(DB::FETCH_CLASS)) {
            $classname = $fetchmode->hasMode(DB::FETCH_CLASSTYPE) ? array_shift($row) : $fetchmode->classname;
            $refl = new \ReflectionClass($classname);
            $obj = $fetchmode->hasMode(DB::FETCH_PROPS_EARLY)
                    ? $refl->newInstanceWithoutConstructor()
                    : $refl->newInstanceArgs($fetchmode->ctor_args);
            $refl = new \ReflectionObject($obj);
            foreach($row as $tag => $value) {
                if($refl->hasProperty($tag)) $refl->getProperty($tag)->setValue($obj, $value);
                else $obj->$tag = $value;
            }
            if($fetchmode->hasMode(DB::FETCH_PROPS_EARLY))
                $refl->getConstructor()->invokeArgs($obj, $fetchmode->ctor_args);
            return $obj;
        }
        if($fetchmode->hasMode(DB::FETCH_INTO)) {
            $refl = new \ReflectionObject($fetchmode->obj);
            foreach($row as $tag => $value) {
                if($refl->hasProperty($tag)) $refl->getProperty($tag)->setValue($obj, $value);
                else $obj->$tag = $value;
            }
        }
    }
final private function parseFetched(array $row, FetchMode $fetchmode) {
        foreach($row as $tag => $value) {
            if(isset($this->parameters[$tag])) {
                $param =& $this->parameters[$tag]['param'];
                $type = $this->parameters[$tag]['type'];
                $param = $this->connection->quote($value, $type);
            }
        }
        if($fetchmode->hasMode(DB::FETCH_BOTH)) return array_merge ($row, array_values ($row));
        if($fetchmode->hasMode(DB::FETCH_ASSOC)) return $row;
        if($fetchmode->hasMode(DB::FETCH_NUM)) return array_values ($row);
        if($fetchmode->hasMode(DB::FETCH_COLUMN)) {
            $values = array_values($row);
            return isset($values[$fetchmode->col]) ? $values[$fetchmode->col] : null;
        }
        if($fetchmode->hasMode(DB::FETCH_OBJ)) return (object)$row;
        if($fetchmode->hasMode(DB::FETCH_CLASS)) {
            $classname = $fetchmode->hasMode(DB::FETCH_CLASSTYPE) ? array_shift($row) : $fetchmode->classname;
            $refl = new \ReflectionClass($classname);
            $obj = $fetchmode->hasMode(DB::FETCH_PROPS_EARLY)
                    ? $refl->newInstanceWithoutConstructor()
                    : $refl->newInstanceArgs($fetchmode->ctor_args);
            $refl = new \ReflectionObject($obj);
            foreach($row as $tag => $value) {
                if($refl->hasProperty($tag)) $refl->getProperty($tag)->setValue($obj, $value);
                else $obj->$tag = $value;
            }
            if($fetchmode->hasMode(DB::FETCH_PROPS_EARLY))
                $refl->getConstructor()->invokeArgs($obj, $fetchmode->ctor_args);
            return $obj;
        }
        if($fetchmode->hasMode(DB::FETCH_INTO)) {
            $refl = new \ReflectionObject($fetchmode->obj);
            foreach($row as $tag => $value) {
                if($refl->hasProperty($tag)) $refl->getProperty($tag)->setValue($obj, $value);
                else $obj->$tag = $value;
            }
        }
    }
final private function parseFetched ( array $ row , FetchMode $ fetchmode ) { foreach ( $ row as $ tag => $ value ) { if ( isset ( $ this -> parameters [ $ tag ] ) ) { $ param = & $ this -> parameters [ $ tag ] [ 'param' ] ; $ type = $ this -> parameters [ $ tag ] [ 'type' ] ; $ param = $ this -> connection -> quote ( $ value , $ type ) ; } } if ( $ fetchmode -> hasMode ( DB :: FETCH_BOTH ) ) return array_merge ( $ row , array_values ( $ row ) ) ; if ( $ fetchmode -> hasMode ( DB :: FETCH_ASSOC ) ) return $ row ; if ( $ fetchmode -> hasMode ( DB :: FETCH_NUM ) ) return array_values ( $ row ) ; if ( $ fetchmode -> hasMode ( DB :: FETCH_COLUMN ) ) { $ values = array_values ( $ row ) ; return isset ( $ values [ $ fetchmode -> col ] ) ? $ values [ $ fetchmode -> col ] : null ; } if ( $ fetchmode -> hasMode ( DB :: FETCH_OBJ ) ) return ( object ) $ row ; if ( $ fetchmode -> hasMode ( DB :: FETCH_CLASS ) ) { $ classname = $ fetchmode -> hasMode ( DB :: FETCH_CLASSTYPE ) ? array_shift ( $ row ) : $ fetchmode -> classname ; $ refl = new \ ReflectionClass ( $ classname ) ; $ obj = $ fetchmode -> hasMode ( DB :: FETCH_PROPS_EARLY ) ? $ refl -> newInstanceWithoutConstructor ( ) : $ refl -> newInstanceArgs ( $ fetchmode -> ctor_args ) ; $ refl = new \ ReflectionObject ( $ obj ) ; foreach ( $ row as $ tag => $ value ) { if ( $ refl -> hasProperty ( $ tag ) ) $ refl -> getProperty ( $ tag ) -> setValue ( $ obj , $ value ) ; else $ obj -> $ tag = $ value ; } if ( $ fetchmode -> hasMode ( DB :: FETCH_PROPS_EARLY ) ) $ refl -> getConstructor ( ) -> invokeArgs ( $ obj , $ fetchmode -> ctor_args ) ; return $ obj ; } if ( $ fetchmode -> hasMode ( DB :: FETCH_INTO ) ) { $ refl = new \ ReflectionObject ( $ fetchmode -> obj ) ; foreach ( $ row as $ tag => $ value ) { if ( $ refl -> hasProperty ( $ tag ) ) $ refl -> getProperty ( $ tag ) -> setValue ( $ obj , $ value ) ; else $ obj -> $ tag = $ value ; } } }
Parse a fetched row, using fetch mode.
This method also populates bound columns.
@param array $row Fetched row to parse
@param FetchMode $fetchmode Fetch mode to use
@return mixed Fetched row, after transformation and parsing based on fetch mode
Parse a fetched row using fetch mode . This method also populates bound columns .