XML_Query2XML
[ class tree: XML_Query2XML ] [ index: XML_Query2XML ] [ all elements ]

Source for file case03.php

Documentation is available at case03.php

  1. <?php
  2. require_once('XML/Query2XML.php');
  3. require_once('DB.php');
  4. $query2xml XML_Query2XML::factory(DB::connect('mysql://root@localhost/Query2XML_Tests'));
  5. $dom $query2xml->getXML(
  6.     "SELECT
  7.         *
  8.      FROM
  9.         artist",
  10.     array(
  11.         'rootTag' => 'music_library',
  12.         'rowTag' => 'artist',
  13.         'idColumn' => 'artistid',
  14.         'elements' => array(
  15.             'artistid',
  16.             'name',
  17.             'birth_year',
  18.             'birth_place',
  19.             'genre',
  20.             'albums' => array(
  21.                 'sql' => array(
  22.                     'data' => array(
  23.                         'artistid'
  24.                     ),
  25.                     'query' => 'SELECT * FROM album WHERE artist_id = ?'
  26.                 ),
  27.                 'sql_options' => array(
  28.                     'uncached'      => true,
  29.                     'single_record' => false,
  30.                     'merge'         => false,
  31.                     'merge_master'  => false
  32.                 ),
  33.                 'rootTag' => 'albums',
  34.                 'rowTag' => 'album',
  35.                 'idColumn' => 'albumid',
  36.                 'elements' => array(
  37.                     'albumid',
  38.                     'title',
  39.                     'published_year',
  40.                     'comment'
  41.                 )
  42.             )
  43.         )
  44.     )
  45. );
  46.  
  47. header('Content-Type: application/xml');
  48. echo '<?xml version="1.0" encoding="UTF-8"?>' "\n";
  49.  
  50. require_once('XML/Beautifier.php');
  51. $beautifier = new XML_Beautifier();
  52. print $beautifier->formatString($dom->saveXML());
  53. ?>

Documentation generated on Mon, 11 Mar 2019 14:47:01 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.