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
 
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
                    'merge_selective' => array('genre')
39
                ),
40
                'rootTag' => '',
41
                'rowTag' => 'ALBUM',
42
                'idColumn' => 'albumid',
43
                'elements' => array(
44
                    'TITLE' => 'title',
45
                    'PUBLISHED_YEAR' => 'published_year',
46
                    'COMMENT' => 'comment',
47
                    'GENRE' => 'genre'
48
                ),
49
                'attributes' => array(
50
                    'ALBUMID' => 'albumid'
51
                )
52
            )
53
        ),
54
        'attributes' => array(
55
            'ARTISTID' => 'artistid',
56
            'MAINTAINER' => ':Lukas Feiler'
57
        )
58
    )
59
);
60
 
61
header('Content-Type: application/xml');
62
 
63
$dom->formatOutput = true;
64
print $dom->saveXML();
65
 
66
require_once 'File.php';
67
$fp = new File();
68
$fp->write('case04.profile', $query2xml->getProfile(), FILE_MODE_WRITE);
69
 
70
function firstTwoChars($record)
71
{
72
    return substr($record['birth_year'], 2);
73
}
74
?>