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

Source for file case04.php

Documentation is available at case04.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.             'NAME' => 'name',
  16.             'BIRTH_YEAR' => 'birth_year',
  17.             'BIRTH_YEAR_TWO_DIGIT' => "!return substr(\"{\$record['birth_year']}\", 2);",
  18.             'BIRTH_PLACE' => 'birth_place',
  19.             'GENRE' => '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.                     'merge_selective' => array('genre')
  30.                 ),
  31.                 'rootTag' => '',
  32.                 'rowTag' => 'ALBUM',
  33.                 'idColumn' => 'albumid',
  34.                 'elements' => array(
  35.                     'TITLE' => 'title',
  36.                     'PUBLISHED_YEAR' => 'published_year',
  37.                     'COMMENT' => 'comment',
  38.                     'GENRE' => 'genre'
  39.                 ),
  40.                 'attributes' => array(
  41.                     'ALBUMID' => 'albumid'
  42.                 )
  43.             )
  44.         ),
  45.         'attributes' => array(
  46.             'ARTISTID' => 'artistid',
  47.             'MAINTAINER' => ':Lukas Feiler'
  48.         )
  49.     )
  50. );
  51.  
  52. header('Content-Type: application/xml');
  53. echo '<?xml version="1.0" encoding="UTF-8"?>' "\n";
  54.  
  55. require_once('XML/Beautifier.php');
  56. $beautifier = new XML_Beautifier();
  57. print $beautifier->formatString($dom->saveXML());
  58. ?>

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