Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
--TEST--
2
XML_Query2XML::getXML(): Case02
3
--SKIPIF--
4
<?php require_once dirname(dirname(__FILE__)) . '/skipif.php'; ?>
5
--FILE--
6
<?php
7
require_once 'XML/Query2XML.php';
8
require_once dirname(dirname(__FILE__)) . '/db_init.php';
9
$query2xml = XML_Query2XML::factory($db);
10
$dom = $query2xml->getXML(
11
    "SELECT
12
        *
13
     FROM
14
        artist
15
        LEFT JOIN album ON album.artist_id = artist.artistid
16
     ORDER BY
17
        artist.artistid,
18
        album.albumid",
19
    array(
20
        'rootTag' => 'music_library',
21
        'rowTag' => 'artist',
22
        'idColumn' => 'artistid',
23
        'elements' => array(
24
            'artistid',
25
            'name',
26
            'birth_year',
27
            'birth_place',
28
            'genre',
29
            'albums' => array(
30
                'rootTag' => 'albums',
31
                'rowTag' => 'album',
32
                'idColumn' => 'albumid',
33
                'elements' => array(
34
                    'albumid',
35
                    'title',
36
                    'published_year',
37
                    'comment'
38
                )
39
            )
40
        )
41
    )
42
);
43
 
44
header('Content-Type: application/xml');
45
 
46
$dom->formatOutput = true;
47
print $dom->saveXML();
48
?>
49
--EXPECT--
50
<?xml version="1.0" encoding="UTF-8"?>
51
<music_library>
52
  <artist>
53
    <artistid>1</artistid>
54
    <name>Curtis Mayfield</name>
55
    <birth_year>1920</birth_year>
56
    <birth_place>Chicago</birth_place>
57
    <genre>Soul</genre>
58
    <albums>
59
      <album>
60
        <albumid>1</albumid>
61
        <title>New World Order</title>
62
        <published_year>1990</published_year>
63
        <comment>the best ever!</comment>
64
      </album>
65
      <album>
66
        <albumid>2</albumid>
67
        <title>Curtis</title>
68
        <published_year>1970</published_year>
69
        <comment>that man's got somthin' to say</comment>
70
      </album>
71
    </albums>
72
  </artist>
73
  <artist>
74
    <artistid>2</artistid>
75
    <name>Isaac Hayes</name>
76
    <birth_year>1942</birth_year>
77
    <birth_place>Tennessee</birth_place>
78
    <genre>Soul</genre>
79
    <albums>
80
      <album>
81
        <albumid>3</albumid>
82
        <title>Shaft</title>
83
        <published_year>1972</published_year>
84
        <comment>he's the man</comment>
85
      </album>
86
    </albums>
87
  </artist>
88
  <artist>
89
    <artistid>3</artistid>
90
    <name>Ray Charles</name>
91
    <birth_year>1930</birth_year>
92
    <birth_place>Mississippi</birth_place>
93
    <genre>Country and Soul</genre>
94
    <albums/>
95
  </artist>
96
</music_library>