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

Source for file case05_debug.php

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

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