Query2XML problem with master-detail
| From: | Diana Quintal | Date: | Sun, 11 Mar 2007 17:08:41 +0000 |
| Subject: | Query2XML problem with master-detail | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-26815@lists.php.net to get a copy of this message | ||
I'm trying to use the Query2XML package and am having
a problem returning a master-detail dataset. I copied
the examples from the documentation but both the left
join and the 2 separate selects only return 1 row of
my detail! If I run the exact same query against the
DB I get 9 detail rows back. I don't know why this
isn't working!! Here is the code for both ways that
I'm trying. I'm using Oracle if that makes a
difference.
Thanks.
Diana
example with a left join:
$dom = $query2xml->getXML(
"SELECT
*
FROM
albums
LEFT JOIN tracks ON albums.album_id =
tracks.album_id
where albums.album_id = '02521801652' ",
array(
'rootTag' => 'music_library',
'rowTag' => 'album',
'idColumn' => 'album_id',
'elements' => array(
'album_id',
'album_name',
'artist',
'tracks' => array(
'rootTag' => 'tracks',
'rowTag' => 'track',
'idColumn' => 'album_id',
'elements' => array(
'album_id',
'track_title'
)
)
)
)
);
example with 2 selects:
$dom = $query2xml->getXML(
"SELECT album_id,album_name, artist, genre_name,
release_date
FROM ALBUMS
WHERE album_id = '02521801652'",
array(
'idColumn' => 'album_id',
'rootTag' => 'album',
'rowTag' =>'details',
'elements' => array(
'title' => 'album_name',
'genre' => 'genre_name',
'artist'=> 'artist',
'releasedate' => 'release_date',
'cuts' => array(
'sql' => array(
'data' => array(
'album_id'
),
'query' => 'SELECT
album_id,track_title from track where album_id = ?'
),
'sql_options' => array(
'uncached' => true,
'single_record' => false,
'merge' => false,
'merge_master' => false
),
'rootTag' => 'cuts',
'rowTag' => 'cut',
'idColumn' => 'album_id',
'elements' => array(
'title'=>'track_title'
)
)
)
)
);
This is the output:
<album>
<details>
<title>FOUR!</title>
<genre>Jazz</genre>
<artist>Hampton Hawes</artist>
<releasedate>1988-12-01 00:00:00</releasedate>
<cuts>
<cut>
<title>There Will Never Be Another You</title>
</cut>
</cuts>
</details>
</album>
____________________________________________________________________________________
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
http://answers.yahoo.com/dir/?link=list&sid=396546091