MySQL Forums
Forum List  »  Connector/Node.js

How receieve XML output from stored procedure into PHP variable
Posted by: Erich Specht
Date: September 24, 2008 09:41AM

I am a recovering Microsoft ASP-SQL Server developer migrating to PHP/mySQL. I'm trying to accomplish the same thing that is easily done in ASP using a stream object to capture the XML output from a stored procedure. I was wondering if anyone could point me in the right direction on how this type of thing can be done in PHP/mySQL. Note: I don't want to create the XML in PHP - I want to write it via the stored procedure.

In ASP, I would do something like this:
==

Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = gameConn_STRING

Set objStream = Server.CreateObject("ADODB.Stream")

cmd.CommandText = "sp_getXML"
cmd.CommandType = adCmdStoredProc

objStream.Open

cmd.Properties("Output Stream").Value = objStream
cmd.Execute , , adExecuteStream

objStream.Position = 0

objStream.Charset = "utf-8"

strXML = objStream.ReadText(adReadAll)
objStream.Close
response.write(strXML)

==
A simple example of what sp_getXML (in MS SQL Server) could do is this:

CREATE PROCEDURE sp_getXML
AS
SELECT '<xmlDocument><dataElement>Here is my data</dataElement></xmlDocument>'
GO

==

When the ASP page calls the stored procedure, the XML document ends up being assigned to the variable strXML and then written to the outputted page.

Please let me know if you have any suggestions on how this can be accomplished in mySQL and PHP.

Thank you for your help.

Erich

Options: ReplyQuote


Subject
Written By
Posted
How receieve XML output from stored procedure into PHP variable
September 24, 2008 09:41AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.