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

Source for file case05.php

Documentation is available at case05.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.          customer c
  10.          LEFT JOIN sale s ON c.customerid = s.customer_id
  11.          LEFT JOIN album al ON s.album_id = al.albumid
  12.          LEFT JOIN artist ar ON al.artist_id = ar.artistid",
  13.     array(
  14.         'rootTag' => 'music_store',
  15.         'rowTag' => 'customer',
  16.         'idColumn' => 'customerid',
  17.         'elements' => array(
  18.             'customerid',
  19.             'first_name',
  20.             'last_name',
  21.             'email',
  22.             'sales' => array(
  23.                 'rootTag' => 'sales',
  24.                 'rowTag' => 'sale',
  25.                 'idColumn' => 'saleid',
  26.                 'elements' => array(
  27.                     'saleid',
  28.                     'timestamp',
  29.                     'date' => "!return substr(\"{\$record['timestamp']}\", 0, strpos(\"{\$record['timestamp']}\", ' '));",
  30.                     'time' => "!return substr(\"{\$record['timestamp']}\", strpos(\"{\$record['timestamp']}\", ' ') + 1);",
  31.                     'album' => array(
  32.                         'rootTag' => '',
  33.                         'rowTag' => 'album',
  34.                         'idColumn' => 'albumid',
  35.                         'elements' => array(
  36.                             'albumid',
  37.                             'title',
  38.                             'published_year',
  39.                             'comment',
  40.                             'artist' => array(
  41.                                 'rootTag' => '',
  42.                                 'rowTag' => 'artist',
  43.                                 'idColumn' => 'artistid',
  44.                                 'elements' => array(
  45.                                     'artistid',
  46.                                     'name',
  47.                                     'birth_year',
  48.                                     'birth_place',
  49.                                     'genre'
  50.                                 //artist elements
  51.                             //artist array
  52.                         //album elements
  53.                     //album array
  54.                 //sales elements
  55.             //sales array
  56.         //root elements
  57.     //root
  58. )//getXML method call
  59.  
  60. $root $dom->firstChild;
  61. $root->setAttribute('date_generated'date("Y-m-d\TH:i:s"1124801570));
  62.  
  63. header('Content-Type: application/xml');
  64. echo '<?xml version="1.0" encoding="UTF-8"?>' "\n";
  65.  
  66. require_once('XML/Beautifier.php');
  67. $beautifier = new XML_Beautifier();
  68. print $beautifier->formatString($dom->saveXML());
  69. ?>

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