| 1 |
lars |
1 |
--TEST--
|
|
|
2 |
XML_Query2XML::getXML(): asterisk shortcut with elements - as placeholder
|
|
|
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 |
ORDER BY
|
|
|
16 |
artistid",
|
|
|
17 |
array(
|
|
|
18 |
'rootTag' => 'music_library',
|
|
|
19 |
'rowTag' => 'artist',
|
|
|
20 |
'idColumn' => 'artistid',
|
|
|
21 |
'elements' => array(
|
|
|
22 |
'*' => '*',
|
|
|
23 |
'TAG1_*' => ':STATIC_VALUE',
|
|
|
24 |
'TAG2_*' => ':VALUE_*',
|
|
|
25 |
'TAG3_*' => '#someManipulation(*)'
|
|
|
26 |
)
|
|
|
27 |
)
|
|
|
28 |
);
|
|
|
29 |
print $dom->saveXML();
|
|
|
30 |
|
|
|
31 |
function someManipulation($record, $columnName)
|
|
|
32 |
{
|
|
|
33 |
return "--" . $record[$columnName] . "--";
|
|
|
34 |
}
|
|
|
35 |
?>
|
|
|
36 |
--EXPECT--
|
|
|
37 |
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
38 |
<music_library><artist><artistid>1</artistid><name>Curtis Mayfield</name><birth_year>1920</birth_year><birth_place>Chicago</birth_place><genre>Soul</genre><TAG1_artistid>STATIC_VALUE</TAG1_artistid><TAG1_name>STATIC_VALUE</TAG1_name><TAG1_birth_year>STATIC_VALUE</TAG1_birth_year><TAG1_birth_place>STATIC_VALUE</TAG1_birth_place><TAG1_genre>STATIC_VALUE</TAG1_genre><TAG2_artistid>VALUE_artistid</TAG2_artistid><TAG2_name>VALUE_name</TAG2_name><TAG2_birth_year>VALUE_birth_year</TAG2_birth_year><TAG2_birth_place>VALUE_birth_place</TAG2_birth_place><TAG2_genre>VALUE_genre</TAG2_genre><TAG3_artistid>--1--</TAG3_artistid><TAG3_name>--Curtis Mayfield--</TAG3_name><TAG3_birth_year>--1920--</TAG3_birth_year><TAG3_birth_place>--Chicago--</TAG3_birth_place><TAG3_genre>--Soul--</TAG3_genre></artist><artist><artistid>2</artistid><name>Isaac Hayes</name><birth_year>1942</birth_year><birth_place>Tennessee</birth_place><genre>Soul</genre><TAG1_artistid>STATIC_VALUE</TAG1_artistid><TAG1_name>STATIC_VALUE</TAG1_name><TAG1_birth_year>STATIC_VALUE</TAG1_birth_year><TAG1_birth_place>STATIC_VALUE</TAG1_birth_place><TAG1_genre>STATIC_VALUE</TAG1_genre><TAG2_artistid>VALUE_artistid</TAG2_artistid><TAG2_name>VALUE_name</TAG2_name><TAG2_birth_year>VALUE_birth_year</TAG2_birth_year><TAG2_birth_place>VALUE_birth_place</TAG2_birth_place><TAG2_genre>VALUE_genre</TAG2_genre><TAG3_artistid>--2--</TAG3_artistid><TAG3_name>--Isaac Hayes--</TAG3_name><TAG3_birth_year>--1942--</TAG3_birth_year><TAG3_birth_place>--Tennessee--</TAG3_birth_place><TAG3_genre>--Soul--</TAG3_genre></artist><artist><artistid>3</artistid><name>Ray Charles</name><birth_year>1930</birth_year><birth_place>Mississippi</birth_place><genre>Country and Soul</genre><TAG1_artistid>STATIC_VALUE</TAG1_artistid><TAG1_name>STATIC_VALUE</TAG1_name><TAG1_birth_year>STATIC_VALUE</TAG1_birth_year><TAG1_birth_place>STATIC_VALUE</TAG1_birth_place><TAG1_genre>STATIC_VALUE</TAG1_genre><TAG2_artistid>VALUE_artistid</TAG2_artistid><TAG2_name>VALUE_name</TAG2_name><TAG2_birth_year>VALUE_birth_year</TAG2_birth_year><TAG2_birth_place>VALUE_birth_place</TAG2_birth_place><TAG2_genre>VALUE_genre</TAG2_genre><TAG3_artistid>--3--</TAG3_artistid><TAG3_name>--Ray Charles--</TAG3_name><TAG3_birth_year>--1930--</TAG3_birth_year><TAG3_birth_place>--Mississippi--</TAG3_birth_place><TAG3_genre>--Country and Soul--</TAG3_genre></artist></music_library>
|