
martinmb
New User
Aug 23, 2002, 9:13 AM
Post #1 of 3
(2575 views)
|
|
recursive query to make an xml tree?
|
Can't Post
|
|
Hi All! I'm trying to work out how to do a recursive MySql query on a table of forum messages to make an xml document. In my messages table I have data fields for id, parent of the message, child of the message and others for the subject, body, time, etc... The DBI 'while fetchrow_array()' loop seems to be stopping the recursion. I am new to perl and DBI and have tried the few things I know to re-write it, without any joy. Please can you help or give me any pointers? Many Thanks! Martin &read_Messages(" WHERE parent = 0"); sub read_Messages{ $myWhere = "@_"; if (!($sth = $dbh->prepare("SELECT $mySelect FROM $myTable $myWhere"))) { snip... execute etc while (my ($id, $parent, $child, $body) = $sth->fetchrow_array()) { ... do stuff if($child != 0){ &read_Messages(" WHERE id = $child"); } } }
|