Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2010
    Posts
    33

    Unanswered: PHP return data as XML data (db2-execute)

    Hello

    I tried to get XML data as described in Example #5 Returning SQL data as part of a larger XML document on page
    PHP: db2_execute - Manual

    <?php

    $conn = db2_connect("SAMPLE", "db2inst1", "ibmdb2");

    $query = '
    SELECT
    XMLSERIALIZE(
    XMLQUERY(\'
    declare boundary-space strip;
    declare default element namespace "http://posample.org";
    <promoList> {
    for $prod in $doc/product
    where $prod/description/price < 10.00
    order by $prod/description/price ascending
    return(
    <promoitem> {
    $prod,
    <startdate> {$start} </startdate>,
    <enddate> {$end} </enddate>,
    <promoprice> {$promo} </promoprice>
    } </promoitem>
    )
    } </promoList>
    \' passing by ref DESCRIPTION AS "doc",
    PROMOSTART as "start",
    PROMOEND as "end",
    PROMOPRICE as "promo"
    RETURNING SEQUENCE)
    AS CLOB (32000))
    AS NEW_PRODUCT_INFO
    FROM PRODUCT
    WHERE PID = ?
    ';

    $stmt = db2_prepare($conn, $query);

    $pid = "100-100-01";

    if ($stmt) {
    db2_bind_param($stmt, 1, "pid", DB2_PARAM_IN);
    db2_execute($stmt);

    while($row = db2_fetch_array($stmt)){
    printf("$row[0]\n");
    }
    }

    db2_close($conn);

    ?>
    instead as result previewed on the page
    <promoList xmlns="http://posample.org">
    <promoitem>
    <product pid="100-100-01">
    <description>
    <name>Snow Shovel, Basic 22 inch</name>
    <details>Basic Snow Shovel, 22 inches wide, straight handle with D-Grip</details>
    <price>9.99</price>
    <weight>1 kg</weight>
    </description>
    </product>
    <startdate>2004-11-19</startdate>
    <enddate>2004-12-19</enddate>
    <promoprice>7.25</promoprice>
    </promoitem>
    </promoList>
    I get the result with no XML Tags like this

    Snow Shovel, Basic 22 inchBasic Snow Shovel, 22 inches wide, straight handle with D-Grip9.991 kg2004-11-192004-12-197.25
    Thanks.

  2. #2
    Join Date
    Sep 2004
    Location
    Belgium
    Posts
    1,126
    Look at the HTML source produced by this PHP (e.g. using Ctrl-U in your browser).
    --_Peter Vanroose,
    __IBM Certified Database Administrator, DB2 9 for z/OS
    __IBM Certified Application Developer
    __ABIS Training and Consulting
    __http://www.abis.be/

  3. #3
    Join Date
    Oct 2010
    Posts
    33
    html source produced shows the xml tags..

    <promoList><promoitem><product pid="100-100-01"><description><name>Snow Shovel, Basic 22 inch</name><details>Basic Snow Shovel, 22 inches wide, straight handle with D-Grip</details><price>9.99</price><weight>1 kg</weight></description></product><startdate>2004-11-19</startdate><enddate>2004-12-19</enddate><promoprice>7.25</promoprice></promoitem></promoList>
    but.. not in the browser

  4. #4
    Join Date
    Sep 2004
    Location
    Belgium
    Posts
    1,126
    You'll have to learn some HTML, then!
    --_Peter Vanroose,
    __IBM Certified Database Administrator, DB2 9 for z/OS
    __IBM Certified Application Developer
    __ABIS Training and Consulting
    __http://www.abis.be/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •