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', 'case03.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
            'artistid',
26
            'name',
27
            'birth_year',
28
            'birth_place',
29
            'genre',
30
            'albums' => array(
31
                'sql' => array(
32
                    'data' => array(
33
                        'artistid'
34
                    ),
35
                    'query' => 'SELECT * FROM album WHERE artist_id = ?'
36
                ),
37
                'rootTag' => 'albums',
38
                'rowTag' => 'album',
39
                'idColumn' => 'albumid',
40
                'elements' => array(
41
                    'albumid',
42
                    'title',
43
                    'published_year',
44
                    'comment'
45
                )
46
            )
47
        )
48
    )
49
);
50
 
51
header('Content-Type: application/xml');
52
 
53
$dom->formatOutput = true;
54
print $dom->saveXML();
55
 
56
require_once 'File.php';
57
$fp = new File();
58
$fp->write('case03.profile', $query2xml->getProfile(), FILE_MODE_WRITE);
59
?>