lib/Face/Sql/Reader/QueryArrayReader.php
public function read(\PDOStatement $stmt)
    {

        $this->unfoundPrecedence=array();

        $preparedReader = new PreparedOperations($this->FQuery);


        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
            // loop over joined faces
            foreach ($preparedReader->getPreparedFaces() as $basePath => $preparedFace) {

                $identity = $preparedFace->rowIdentity($row, $basePath);

                if ($identity) {
                    // if already instantiated then get it from ikeeper and try the forwards
                    if ($this->instancesKeeper->hasInstance($preparedFace->getFace()->getClass(), $identity)) {
                        $instance = $this->instancesKeeper->getInstance($preparedFace->getFace()->getClass(), $identity);

                        $preparedFace->runOperations($instance,$row,$this->instancesKeeper, $this->unfoundPrecedence);

                        if (!$this->resultSet->pathHasIdentity($basePath, $identity)) {
                            $this->resultSet->addInstanceByPath($basePath, $instance, $identity);
                        }

                        // else create the instance and hydrate it
                    } else {
                        $instance = $this->createInstance($preparedFace->getFace());
                        $this->instancesKeeper->addInstance($instance, $identity);
                        $this->resultSet->addInstanceByPath($basePath, $instance, $identity);

                        $preparedFace->runOperations($instance,$row,$this->instancesKeeper, $this->unfoundPrecedence);

                    }
                }

            }


        }

        // set unset instances. To be improved ?
        foreach ($this->unfoundPrecedence as $unfound) {

            if(!$this->instancesKeeper->hasInstance($unfound['elementToSet']->getClass(), $unfound['identityOfElement'])){

                var_dump($unfound['elementToSet']->getClass());
                var_dump($unfound['identityOfElement']);
                var_dump(get_class($instance));

            }

            $unfoundInstance = $this->instancesKeeper->getInstance($unfound['elementToSet']->getClass(), $unfound['identityOfElement']);
            $unfound['instance']->faceSetter($unfound['elementToSet'], $unfoundInstance);
        }


        return $this->resultSet;

    }
public function read(\PDOStatement $stmt)
    {

        $this->unfoundPrecedence=array();

        $preparedReader = new PreparedOperations($this->FQuery);


        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
            // loop over joined faces
            foreach ($preparedReader->getPreparedFaces() as $basePath => $preparedFace) {

                $identity = $preparedFace->rowIdentity($row, $basePath);

                if ($identity) {
                    // if already instantiated then get it from ikeeper and try the forwards
                    if ($this->instancesKeeper->hasInstance($preparedFace->getFace()->getClass(), $identity)) {
                        $instance = $this->instancesKeeper->getInstance($preparedFace->getFace()->getClass(), $identity);

                        $preparedFace->runOperations($instance,$row,$this->instancesKeeper, $this->unfoundPrecedence);

                        if (!$this->resultSet->pathHasIdentity($basePath, $identity)) {
                            $this->resultSet->addInstanceByPath($basePath, $instance, $identity);
                        }

                        // else create the instance and hydrate it
                    } else {
                        $instance = $this->createInstance($preparedFace->getFace());
                        $this->instancesKeeper->addInstance($instance, $identity);
                        $this->resultSet->addInstanceByPath($basePath, $instance, $identity);

                        $preparedFace->runOperations($instance,$row,$this->instancesKeeper, $this->unfoundPrecedence);

                    }
                }

            }


        }

        // set unset instances. To be improved ?
        foreach ($this->unfoundPrecedence as $unfound) {

            if(!$this->instancesKeeper->hasInstance($unfound['elementToSet']->getClass(), $unfound['identityOfElement'])){

                var_dump($unfound['elementToSet']->getClass());
                var_dump($unfound['identityOfElement']);
                var_dump(get_class($instance));

            }

            $unfoundInstance = $this->instancesKeeper->getInstance($unfound['elementToSet']->getClass(), $unfound['identityOfElement']);
            $unfound['instance']->faceSetter($unfound['elementToSet'], $unfoundInstance);
        }


        return $this->resultSet;

    }
public function read ( \ PDOStatement $ stmt ) { $ this -> unfoundPrecedence = array ( ) ; $ preparedReader = new PreparedOperations ( $ this -> FQuery ) ; while ( $ row = $ stmt -> fetch ( \ PDO :: FETCH_ASSOC ) ) { // loop over joined faces foreach ( $ preparedReader -> getPreparedFaces ( ) as $ basePath => $ preparedFace ) { $ identity = $ preparedFace -> rowIdentity ( $ row , $ basePath ) ; if ( $ identity ) { // if already instantiated then get it from ikeeper and try the forwards if ( $ this -> instancesKeeper -> hasInstance ( $ preparedFace -> getFace ( ) -> getClass ( ) , $ identity ) ) { $ instance = $ this -> instancesKeeper -> getInstance ( $ preparedFace -> getFace ( ) -> getClass ( ) , $ identity ) ; $ preparedFace -> runOperations ( $ instance , $ row , $ this -> instancesKeeper , $ this -> unfoundPrecedence ) ; if ( ! $ this -> resultSet -> pathHasIdentity ( $ basePath , $ identity ) ) { $ this -> resultSet -> addInstanceByPath ( $ basePath , $ instance , $ identity ) ; } // else create the instance and hydrate it } else { $ instance = $ this -> createInstance ( $ preparedFace -> getFace ( ) ) ; $ this -> instancesKeeper -> addInstance ( $ instance , $ identity ) ; $ this -> resultSet -> addInstanceByPath ( $ basePath , $ instance , $ identity ) ; $ preparedFace -> runOperations ( $ instance , $ row , $ this -> instancesKeeper , $ this -> unfoundPrecedence ) ; } } } } // set unset instances. To be improved ? foreach ( $ this -> unfoundPrecedence as $ unfound ) { if ( ! $ this -> instancesKeeper -> hasInstance ( $ unfound [ 'elementToSet' ] -> getClass ( ) , $ unfound [ 'identityOfElement' ] ) ) { var_dump ( $ unfound [ 'elementToSet' ] -> getClass ( ) ) ; var_dump ( $ unfound [ 'identityOfElement' ] ) ; var_dump ( get_class ( $ instance ) ) ; } $ unfoundInstance = $ this -> instancesKeeper -> getInstance ( $ unfound [ 'elementToSet' ] -> getClass ( ) , $ unfound [ 'identityOfElement' ] ) ; $ unfound [ 'instance' ] -> faceSetter ( $ unfound [ 'elementToSet' ] , $ unfoundInstance ) ; } return $ this -> resultSet ; }
parse the pdo statement of the fquery
@param \PDOStatement $stmt
@return \Face\Sql\Result\ResultSet
parse the pdo statement of the fquery