Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 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
$dom = $query2xml->getXML(
6
    "SELECT
7
        *
8
     FROM
9
        artist
10
     ORDER BY
11
        artistid",
12
    array(
13
        'rootTag' => 'MUSIC_LIBRARY',
14
        'rowTag' => 'ARTIST',
15
        'idColumn' => 'artistid',
16
        'elements' => array(
17
            'NAME' => 'name',
18
            'BIRTH_YEAR' => 'birth_year',
19
            'BIRTH_YEAR_TWO_DIGIT' => "#firstTwoChars()",
20
            'BIRTH_PLACE' => 'birth_place',
21
            'GENRE' => 'genre',
22
            'albums' => array(
23
                'sql' => array(
24
                    'data' => array(
25
                        'artistid'
26
                    ),
27
                    'query' => 'SELECT * FROM album WHERE artist_id = ?'
28
                ),
29
                '_sql_options' => array(
30
                    'merge_selective' => array('genre')
31
                ),
32
                'rootTag' => '',
33
                'rowTag' => 'ALBUM',
34
                'idColumn' => 'albumid',
35
                'elements' => array(
36
                    'TITLE' => 'title',
37
                    'PUBLISHED_YEAR' => 'published_year',
38
                    'COMMENT' => 'comment',
39
                    'GENRE' => 'genre'
40
                ),
41
                'attributes' => array(
42
                    'ALBUMID' => 'albumid'
43
                )
44
            )
45
        ),
46
        'attributes' => array(
47
            'ARTISTID' => 'artistid',
48
            'MAINTAINER' => ':Lukas Feiler'
49
        )
50
    )
51
);
52
 
53
header('Content-Type: application/xml');
54
 
55
$dom->formatOutput = true;
56
print $dom->saveXML();
57
 
58
function firstTwoChars($record)
59
{
60
    return substr($record['birth_year'], 2);
61
}
62
?>