FluentDOM\Loader\PHP\PDO::load PHP Méthode

load() public méthode

See also: Loadable::load
public load ( PDOStatement $source, string $contentType, array | Traversable | Options $options = [] ) : Document | Result | null
$source PDOStatement
$contentType string
$options array | Traversable | Options
Résultat FluentDOM\Document | FluentDOM\Loader\Result | null
    public function load($source, $contentType, $options = [])
    {
        if ($source instanceof \PDOStatement) {
            $document = new Document('1.0', 'UTF-8');
            $document->registerNamespace('json', self::XMLNS);
            $root = $document->appendElement('json:json');
            $source->setFetchMode(\PDO::FETCH_OBJ);
            foreach ($source as $row) {
                $child = $root->appendElement('_');
                $this->transferTo($child, $row, 1);
            }
            return new Result($document, 'text/xml');
        }
        return NULL;
    }