Fetching data from Oracle into XML - Google Maps API

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
hegelsHoliday
Forum Newbie
Posts: 2
Joined: Wed Aug 27, 2008 4:49 pm

Fetching data from Oracle into XML - Google Maps API

Post by hegelsHoliday »

I am trying to convert the Google Maps API example - Creating a Store Locator with PHP, MySQL & Google Maps - from MySQL to Oracle. I am almost done, but I am having a problem near the end where data from the database is added to XML. Can anyone help me?

[...]
//Program ok up to here, made connection, query database, etc, but then...

header("Content-type: text/xml");

// Iterate through the rows, adding XML nodes for each record
// Done like this with MySQL data and it works:
//while ($row = @mysql_fetch_assoc($result)){
// $node = $dom->createElement("marker");
// $newnode = $parnode->appendChild($node);
// $newnode->setAttribute("name", $row['id']);
// $newnode->setAttribute("address", $row['address']);
// $newnode->setAttribute("lat", $row['slat']);
// $newnode->setAttribute("lng", $row['slng']);
// $newnode->setAttribute("distance", $row['distance']);
//}

// How do I do this with Oracle? The following doesn't create a runtime error but it is returning 'documentElement is null
// or not an object', which means it ain't returning the data!
while ($row = oci_fetch_array ($statement, oci_assoc)) {
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("name", $row['id']);
$newnode->setAttribute("address", $row['address']);
$newnode->setAttribute("lat", $row['slat']);
$newnode->setAttribute("lng", $row['slng']);
$newnode->setAttribute("distance", $row['distance']);
}

// Break connection
oci_logoff($connection);

echo $dom->saveXML();

//End
User avatar
ghurtado
Forum Contributor
Posts: 334
Joined: Wed Jul 23, 2008 12:19 pm

Re: Fetching data from Oracle into XML - Google Maps API

Post by ghurtado »

Are you sure there is data? did you try executing the SQL query in Oracle directly?
hegelsHoliday
Forum Newbie
Posts: 2
Joined: Wed Aug 27, 2008 4:49 pm

Re: Fetching data from Oracle into XML - Google Maps API

Post by hegelsHoliday »

Yes, there is data in the table and the query works. I tested the code up to the point where I show the code in my question.
User avatar
ghurtado
Forum Contributor
Posts: 334
Joined: Wed Jul 23, 2008 12:19 pm

Re: Fetching data from Oracle into XML - Google Maps API

Post by ghurtado »

How many times does your code iterate through the oracle resultset? (how many times it runs through the while loop)
User avatar
ghurtado
Forum Contributor
Posts: 334
Joined: Wed Jul 23, 2008 12:19 pm

Re: Fetching data from Oracle into XML - Google Maps API

Post by ghurtado »

By the way:
//Program ok up to here, made connection, query database, etc, but then...
"Program ok up to here" could be a pretty big assumption. You should probably show us the rest of the code, at least the part that connects to the database. Where does $statement get declared?
Post Reply