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

Source for file case04_debug.php

Documentation is available at case04_debug.php

  1. <?php
  2. require_once 'XML/Query2XML.php';
  3. require_once 'MDB2.php';
  4. $query2xml XML_Query2XML::factory(MDB2::factory('mysql://root@localhost/Query2XML_Tests'));
  5.  
  6. require_once 'Log.php';
  7. $debugLogger &Log::factory('file''case04.log''Query2XML');
  8. $query2xml->enableDebugLog($debugLogger);
  9.  
  10. $query2xml->startProfiling();
  11.  
  12.  
  13. $dom $query2xml->getXML(
  14.     "SELECT
  15.         *
  16.      FROM
  17.         artist
  18.      ORDER BY
  19.         artistid",
  20.     array(
  21.         'rootTag' => 'MUSIC_LIBRARY',
  22.         'rowTag' => 'ARTIST',
  23.         'idColumn' => 'artistid',
  24.         'elements' => array(
  25.             'NAME' => 'name',
  26.             'BIRTH_YEAR' => 'birth_year',
  27.             'BIRTH_YEAR_TWO_DIGIT' => "#firstTwoChars()",
  28.             'BIRTH_PLACE' => 'birth_place',
  29.             'GENRE' => 'genre',
  30.             'albums' => array(
  31.                 'sql' => array(
  32.                     'data' => array(
  33.                         'artistid'
  34.                     ),
  35.                     'query' => 'SELECT * FROM album WHERE artist_id = ?'
  36.                 ),
  37.                 'sql_options' => array(
  38.                     'uncached'        => true,
  39.                     'merge_selective' => array('genre')
  40.                 ),
  41.                 'rootTag' => '',
  42.                 'rowTag' => 'ALBUM',
  43.                 'idColumn' => 'albumid',
  44.                 'elements' => array(
  45.                     'TITLE' => 'title',
  46.                     'PUBLISHED_YEAR' => 'published_year',
  47.                     'COMMENT' => 'comment',
  48.                     'GENRE' => 'genre'
  49.                 ),
  50.                 'attributes' => array(
  51.                     'ALBUMID' => 'albumid'
  52.                 )
  53.             )
  54.         ),
  55.         'attributes' => array(
  56.             'ARTISTID' => 'artistid',
  57.             'MAINTAINER' => ':Lukas Feiler'
  58.         )
  59.     )
  60. );
  61.  
  62. header('Content-Type: application/xml');
  63.  
  64. $dom->formatOutput = true;
  65. print $dom->saveXML();
  66.  
  67. require_once 'File.php';
  68. $fp = new File();
  69. $fp->write('case04.profile'$query2xml->getProfile()FILE_MODE_WRITE);
  70.  
  71. function firstTwoChars($record)
  72. {
  73.     return substr($record['birth_year']2);
  74. }
  75. ?>

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