navigation

news

2006-12-20

Changed the project name to libmyxql

2006-09-08

The library gets a new website

external links

licence

libmyxql is available under the LGPL licence. Please read the license carefully before using the library.

developed by

Arnold Daniëls

script examples

PHP implementation - mysql extension

$result = mysql_query("SELECT xql_agg_root('root', xql_element('node', description)) FROM `mytable`");
$xml = mysql_result($result, 0);

PHP implementation - mysqli extension

$result = $db->query("SELECT xql_agg_root('root', xql_element('node', description)) FROM `mytable`");
list($xml) = $result->fetch_row();

query examples

Simple flat result

SELECT xql_agg_root('classes', xql_element('class', null, 'name', concat(grade, suffix), 'teacher', teacher)) FROM schoolclass;

<classes>
 <class name="1A" teacher="Pullen"/>
 <class name="2A" teacher="Berg"/>
 <class name="3A" teacher="Heijden"/>
 <class name="3B" teacher="Ven"/>
 <class name="4A" teacher="Theunissen"/>
 <class name="4B" teacher="Huizingh"/>
 <class name="4C" teacher="Groot"/>
 <class name="5A" teacher="Brongers"/>
 <class name="5B" teacher="Zijlstra"/>
 <class name="6A" teacher="Brommer"/>
 <class name="7A" teacher="Nimwegen"/>
 <class name="7B" teacher="Lede"/>
 <class name="8A" teacher="Spaansen"/>
 <class name="8B" teacher="Wiersma"/>
</classes>
          

Simple tree result

SELECT xql_agg_root('classes', class_node) FROM
(SELECT xql_root('class', xql_agg(xql_forest_el('pupil', 'firstname', firstname, 'lastname', lastname)), 'name', concat(grade, suffix), 'teacher', teacher) AS class_node FROM schoolclass LEFT JOIN pupil ON schoolclass.id = pupil.schoolclass_id WHERE grade = 3 GROUP BY schoolclass.id) AS x

<classes>
 <class name="3A" teacher="Heijden">
  <pupil><firstname>Toon</firstname><lastname>Baars</lastname></pupil>
  <pupil><firstname>Guido</firstname><lastname>Nas</lastname></pupil>
  <pupil><firstname>Steven</firstname><lastname>Schijndel</lastname></pupil>
  <pupil><firstname>Renz</firstname><lastname>Pijnenborgh</lastname></pupil>
  <pupil><firstname>Cees</firstname><lastname>Star</lastname></pupil>
  <pupil><firstname>Ellen</firstname><lastname>Gommers</lastname></pupil>
  <pupil><firstname>Pim</firstname><lastname>Thoonen</lastname></pupil>
  <pupil><firstname>Jet</firstname><lastname>Lasseur</lastname></pupil>
  <pupil><firstname>Lucy</firstname><lastname>Donker</lastname></pupil>
  <pupil><firstname>Richard</firstname><lastname>Bosman</lastname></pupil>
  <pupil><firstname>Roelie</firstname><lastname>Pol</lastname></pupil>
  <pupil><firstname>Hans</firstname><lastname>Stralen</lastname></pupil>
  <pupil><firstname>Marcel</firstname><lastname>Rademaker</lastname></pupil>
  <pupil><firstname>Mark</firstname><lastname>Pessel</lastname></pupil>
  <pupil><firstname>Kees</firstname><lastname>Blonk</lastname></pupil>
  <pupil><firstname>Christy</firstname><lastname>Dijk</lastname></pupil>
  <pupil><firstname>Herman</firstname><lastname>Vroome</lastname></pupil>
  <pupil><firstname>Nina</firstname><lastname>Viegers</lastname></pupil>
  <pupil><firstname>Jan</firstname><lastname>Logtenberg</lastname></pupil>
  <pupil><firstname>Test</firstname><lastname>Test</lastname></pupil>
  <pupil><firstname>Frits</firstname><lastname>Schaafsma</lastname></pupil>
  <pupil><firstname>Willem</firstname><lastname>Ostendorf</lastname></pupil>
  <pupil><firstname>Peter</firstname><lastname>Boorn</lastname></pupil>
 </class>
 <class name="3B" teacher="Ven">
  <pupil><firstname>Bas</firstname><lastname>Govers</lastname></pupil>
  <pupil><firstname>Nico</firstname><lastname>Pol</lastname></pupil>
  <pupil><firstname>Adolf</firstname><lastname>Lozeman</lastname></pupil>
  <pupil><firstname>Albert</firstname><lastname>Visch</lastname></pupil>
  <pupil><firstname>Reitte</firstname><lastname>Scholderman</lastname></pupil>
  <pupil><firstname>Hellen</firstname><lastname>Batterink</lastname></pupil>
  <pupil><firstname>Syb</firstname><lastname>Hoekstra</lastname></pupil>
  <pupil><firstname>Ger</firstname><lastname>beijers</lastname></pupil>
  <pupil><firstname>Lisa</firstname><lastname>Martin</lastname></pupil>
  <pupil><firstname>Erik</firstname><lastname>Scheijndel</lastname></pupil>
  <pupil><firstname>Rob</firstname><lastname>Hazelaar</lastname></pupil>
  <pupil><firstname>Theo</firstname><lastname>Veldboer</lastname></pupil>
  <pupil><firstname>Jos</firstname><lastname>Drost</lastname></pupil>
  <pupil><firstname>M.</firstname><lastname>Dijkshorn</lastname></pupil>
  <pupil><firstname>Sjaak</firstname><lastname>Verzijl</lastname></pupil>
  <pupil><firstname>Nina</firstname><lastname>Kremers</lastname></pupil>
  <pupil><firstname>Monique</firstname><lastname>Weesie</lastname></pupil>
  <pupil><firstname>Jorien</firstname><lastname>Smits</lastname></pupil>
  <pupil><firstname>Jos</firstname><lastname>Berg</lastname></pupil>
  <pupil><firstname>Herman</firstname><lastname>Eldering</lastname></pupil>
  <pupil><firstname>Floris</firstname><lastname>Droogh</lastname></pupil>
  <pupil><firstname>Douwe</firstname><lastname>Verburg</lastname></pupil>
  <pupil><firstname>Ton</firstname><lastname>Lamers</lastname></pupil>
  <pupil><firstname>Ronald</firstname><lastname>Koopmanschap</lastname></pupil>
  <pupil><firstname>Fred</firstname><lastname>Weijde</lastname></pupil>
  <pupil><firstname>Vincent</firstname><lastname>Rodijk</lastname></pupil>
  <pupil><firstname>Els</firstname><lastname>Koene-van Leeuwen</lastname></pupil>
 </class>
</classes>