Re: PDO_FETCH_XML fro PDO

From: Date: Mon, 24 Oct 2005 14:55:50 +0000
Subject: Re: PDO_FETCH_XML fro PDO
References: 1 2 3  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-3142@lists.php.net to get a copy of this message
It sounds to me like you can use PDO::FETCH_FUNC and have your own function generate the XML, and that the end result will be much more flexible. --Wez. On 10/24/05, Justin Wu <ezdevelop@gmail.com> wrote: > Sorry, I will attach it again. > The isea is from my framework, I'v wrote a PHP Framework, using a lot of > PHP5 feature, like PDO, XML, XSLT etc. Also I use the XSLT as the template > engine. like this: > template.php > ========= > class template { > public function assign($var, $value) { > // hold the assigned template variables > ... > } > > public function display($xslfile) { > // 1. convert the assigned template variables to xml format used for > XSL files, so I can do something in the XSL files > // 2. call XSLT transform > // 3. display the result > $doc = new DOMDocument('1.0', 'UTF-8'); > $xml = '<root>'. $this->buildXML($this->tpldata) . > '</root>'; > $doc->loadXML($xml); > $xsl = new XSLTProcessor(); > $xsl->importStyleSheet(DOMDocument::load($xslfile)); > echo $xsl->transformToXML($doc); > } > } > test.tpl.xsl > ===== > <xsl:stylesheet version="1.0" > xmlns:xhtml="http://www.w3.org/1999/xhtml" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:output method="html" doctype-public="-//W3C//DTD XHTML 1.0 > Transitional//EN" > > doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > /> > <xsl:template match="/"> > <table border="1"> > <xsl:apply-templates/> > </table> > </xsl:template> > <xsl:template match="//news/resultset/"> > <xsl:for-each select="row"> > <tr ><td><xsl:value-of select="id" > /></td><td><xsl:value-of > select="title" /></td></tr> > </xsl:for-each> > </xsl:template> > </xsl:stylesheet> > test.php > ====== > include("template.php"); > //do some query in the database > $dbh = new PDO(...); > $stmt = $dbh->query("SELECT * FROM news"); > $tpl = new Template(); > $tpl->assign('news', $stmt); > $tpl->display('test.tpl.xsl'); > > the problem is that need run 2 steps: > 1. fetch the records. > 2. convert the record to xml format. > So if the the records is big enough, it will spent much more times. > > So I have an idea to add PDO_FETCH_XML feature to PDO, I think this will > save any times. > > regards, > --Justin > > ----- Original Message ----- > From: "Wez Furlong" <kingwez@gmail.com> > Newsgroups: php.pecl.dev > To: "Justin Wu" <ezdevelop@gmail.com> > Cc: <pecl-dev@lists.php.net> > Sent: Monday, October 24, 2005 10:00 PM > Subject: Re: [PECL-DEV] PDO_FETCH_XML fro PDO > > > Can you put the attachment online, or attach it as a MIME plain text > attachment? > Also, an example of what comes back would be useful to get a better > idea of the patch. > > --Wez. > > -- > PECL development discussion Mailing List (http://pecl.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.pecl.dev (#3142) next »