cvs: pear /XML_Query2XML/tutorials/XML_Query2XML XML_Query2XML.pkg
| From: | Lukas Feiler | Date: | Fri, 27 Oct 2006 22:10:44 +0000 |
| Subject: | cvs: pear /XML_Query2XML/tutorials/XML_Query2XML XML_Query2XML.pkg | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-42840@lists.php.net to get a copy of this message | ||
lukasfeiler Fri Oct 27 22:10:44 2006 UTC
Modified files:
/pear/XML_Query2XML/tutorials/XML_Query2XML XML_Query2XML.pkg
Log:
some clarifications and one additional demonstration of the asterisk shortcut
http://cvs.php.net/viewvc.cgi/pear/XML_Query2XML/tutorials/XML_Query2XML/XML_Query2XML.pkg?r1=1.2&r2=1.3&diff_format=u
Index: pear/XML_Query2XML/tutorials/XML_Query2XML/XML_Query2XML.pkg
diff -u pear/XML_Query2XML/tutorials/XML_Query2XML/XML_Query2XML.pkg:1.2
pear/XML_Query2XML/tutorials/XML_Query2XML/XML_Query2XML.pkg:1.3
--- pear/XML_Query2XML/tutorials/XML_Query2XML/XML_Query2XML.pkg:1.2 Sat Oct 14 19:28:32 2006
+++ pear/XML_Query2XML/tutorials/XML_Query2XML/XML_Query2XML.pkg Fri Oct 27 22:10:43 2006
@@ -621,6 +621,10 @@
<refsect3 id="{@id asterisk_shortcut}">
<title>Using the Asterisk Shortcut</title>
<para>
+ The asterisk shortcut only works with {@tutorial
XML_Query2XML.pkg#query2xml_getxml.options_elements.simple_element_specifications}
+ (and {@tutorial
XML_Query2XML.pkg#query2xml_getxml.options_attributes.simple_attribute_specifications}).
+ </para>
+ <para>
In some scenarios you will just want to use all columns found in the result set
for {@tutorial
XML_Query2XML.pkg#query2xml_getxml.options_elements.simple_element_specifications}.
This is where the asterisk shortcut can come in very handy. An element specification that
@@ -859,7 +863,7 @@
</programlisting>
</para>
<para>
- If we wanted to include all columns in the XML output but "genre" we could use a
little trick:
+ If we wanted to include all columns in the XML output except "genre" we could use a
little trick:
<programlisting role="php">
<![CDATA[
<?php
@@ -909,6 +913,32 @@
</favorite_artists>
]]>
</programlisting>
+ The exact same result could of course also be achieved using the "condition"
option:
+ <programlisting role="php">
+ <![CDATA[
+<?php
+require_once('XML/Query2XML.php');
+require_once('DB.php');
+$query2xml =
XML_Query2XML::factory(DB::connect('mysql://root@localhost/Query2XML_Tests'));
+$dom = $query2xml->getXML(
+ "SELECT * FROM artist",
+ array(
+ 'rootTag' => 'favorite_artists',
+ 'idColumn' => 'artistid',
+ 'rowTag' => 'artist',
+ 'elements' => array(
+ '*' => '*',
+ 'genre' => array(
+ 'condition' => 'false'
+ )
+ )
+ )
+);
+header('Content-Type: application/xml');
+print $dom->saveXML();
+?>
+ ]]>
+ </programlisting>
</para>
<para>
One final note on the asterisk shortcut: if you explicitly specify a tag name (an array
element key) it has to contain an asterisk. The following code
@@ -955,7 +985,7 @@
)
]]>
</programlisting>
- just makes no sense and therfore "*" is treated as a regular name of column - which
does not exist in this case!
+ just makes no sense and therfore "*" is treated as a regular column name - which
does not exist in this case!
The exception's message would read: The column "*" used in the option
"elements" does not exist in the result set.
</para>
</refsect3>
@@ -1243,7 +1273,11 @@
<refsect3 id="{@id asterisk_shortcut}">
<title>Using the Asterisk Shortcut</title>
<para>
- Everything said about using the
+ The asterisk shortcut only works with {@tutorial
XML_Query2XML.pkg#query2xml_getxml.options_attributes.simple_attribute_specifications}
+ (and {@tutorial
XML_Query2XML.pkg#query2xml_getxml.options_elements.simple_element_specifications}).
+ </para>
+ <para>
+ Everything said about
{@tutorial XML_Query2XML.pkg#query2xml_getxml.options_elements.asterisk_shortcut Using the
Asterisk Shortcut with simple element specifications}
applies here to!
The simplest example of using the asterisk shortcut with the attributes option is as follows: