| 1 |
lars |
1 |
--TEST--
|
|
|
2 |
XML_Query2XML::getXML(): asterisk shortcut with attributes - 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 |
'attributes' => array(
|
|
|
22 |
'*' => '*',
|
|
|
23 |
'ATTR1_*' => ':STATIC_VALUE',
|
|
|
24 |
'ATTR2_*' => ':VALUE_*',
|
|
|
25 |
'ATTR3_*' => '#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" name="Curtis Mayfield" birth_year="1920" birth_place="Chicago" genre="Soul" ATTR1_artistid="STATIC_VALUE" ATTR1_name="STATIC_VALUE" ATTR1_birth_year="STATIC_VALUE" ATTR1_birth_place="STATIC_VALUE" ATTR1_genre="STATIC_VALUE" ATTR2_artistid="VALUE_artistid" ATTR2_name="VALUE_name" ATTR2_birth_year="VALUE_birth_year" ATTR2_birth_place="VALUE_birth_place" ATTR2_genre="VALUE_genre" ATTR3_artistid="--1--" ATTR3_name="--Curtis Mayfield--" ATTR3_birth_year="--1920--" ATTR3_birth_place="--Chicago--" ATTR3_genre="--Soul--"/><artist artistid="2" name="Isaac Hayes" birth_year="1942" birth_place="Tennessee" genre="Soul" ATTR1_artistid="STATIC_VALUE" ATTR1_name="STATIC_VALUE" ATTR1_birth_year="STATIC_VALUE" ATTR1_birth_place="STATIC_VALUE" ATTR1_genre="STATIC_VALUE" ATTR2_artistid="VALUE_artistid" ATTR2_name="VALUE_name" ATTR2_birth_year="VALUE_birth_year" ATTR2_birth_place="VALUE_birth_place" ATTR2_genre="VALUE_genre" ATTR3_artistid="--2--" ATTR3_name="--Isaac Hayes--" ATTR3_birth_year="--1942--" ATTR3_birth_place="--Tennessee--" ATTR3_genre="--Soul--"/><artist artistid="3" name="Ray Charles" birth_year="1930" birth_place="Mississippi" genre="Country and Soul" ATTR1_artistid="STATIC_VALUE" ATTR1_name="STATIC_VALUE" ATTR1_birth_year="STATIC_VALUE" ATTR1_birth_place="STATIC_VALUE" ATTR1_genre="STATIC_VALUE" ATTR2_artistid="VALUE_artistid" ATTR2_name="VALUE_name" ATTR2_birth_year="VALUE_birth_year" ATTR2_birth_place="VALUE_birth_place" ATTR2_genre="VALUE_genre" ATTR3_artistid="--3--" ATTR3_name="--Ray Charles--" ATTR3_birth_year="--1930--" ATTR3_birth_place="--Mississippi--" ATTR3_genre="--Country and Soul--"/></music_library>
|