XML and PHP problem

The place for general PHP questions and hints for PHP on IBM i

XML and PHP problem

Postby gdumas on Tue Jul 03, 2012 11:18 am

Hi,
I'm in V7.1 and Zend Server 5.6 and I have a problem to retrieve the new type of column XML.
I search to retrieve a result set with PHP after calling a stored procedure. It's work fine with a stored procedure who not returned XML column but when XML column is present, I don't have result...

My PHP code :
$cpro = db2_prepare($cnx,"CALL TEST_OMNI.SEARCH( ? , ? ) ");
$BIB="PHPSPL_IDX";
$SEARCH="ANANAS";
db2_bind_param($cpro, 1, 'BIB', DB2_PARAM_IN);
db2_bind_param($cpro, 2, 'SEARCH', DB2_PARAM_IN);
if (db2_execute($cpro)) {
while ($row = db2_fetch_object($cpro)) {
echo "{$row[0]}, {$row[1]}, {$row[2]}, {$row[3]}
";
}
}else {
echo "ERR";
}


The stored procedure SEARCH is a stored procedure of OMNIFIND. The same call in Iseries Navigator works fine.

Any idea ?


DUMAS Gautier
gdumas
 
Posts: 3
Joined: Tue Jul 03, 2012 11:05 am

Re: XML and PHP problem

Postby aseiden on Tue Jul 03, 2012 5:29 pm

Is it possible that PHP is retrieving the XML but it doesn't display easily in your HTML-based browser?

Try "View Source" in your browser and see if the XML is there.

--Alan Seiden
aseiden
 
Posts: 697
Joined: Thu Apr 09, 2009 5:45 pm

Re: XML and PHP problem

Postby gdumas on Wed Jul 04, 2012 11:04 am

I think it's not a display problem. My cursor is just empty when the result set contain ONE XML column (and other types of column). When the result set doesn't contain a XML column, I can display this with the same method.
Thanks for your time !! I continue to seek a solution.

Has anyone ever dealt with a field of type XML in DB2 with PHP ?

--DUMAS Gautier
gdumas
 
Posts: 3
Joined: Tue Jul 03, 2012 11:05 am

Re: XML and PHP problem

Postby gdumas on Fri Jul 06, 2012 10:42 am

Hi,

I found a solution to retrieve a column of type XML from DB2 with PHP. You must use the scalar function XMLSERIALIZE.
Example :
I have the file TESTXML in the library PHPBIB. TESTXML has just one column TEST of type XML.
The right SQL request is :
SELECT XMLSERIALIZE(TEST AS CHAR(500) CCSID 1208) AS "RESULT"
FROM PHPBIB.TESTXML

--DUMAS Gautier
gdumas
 
Posts: 3
Joined: Tue Jul 03, 2012 11:05 am


Return to PHP Questions / Hints

Who is online

Users browsing this forum: No registered users and 1 guest