Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 506

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>db2_execute</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="IBM DB2, Cloudscape and Apache Derby Functions"
HREF="ref.ibm-db2.html"><LINK
REL="PREVIOUS"
TITLE="db2_exec"
HREF="function.db2-exec.html"><LINK
REL="NEXT"
TITLE="db2_fetch_array"
HREF="function.db2-fetch-array.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.db2-exec.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.db2-fetch-array.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.db2-execute"
></A
>db2_execute</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN80611"
></A
><P
>    (PECL)</P
>db2_execute&nbsp;--&nbsp;
   Executes a prepared SQL statement
  </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN80614"
></A
><H2
>说明</H2
>bool <B
CLASS="methodname"
>db2_execute</B
> ( resource stmt [, array parameters] )<BR
></BR
><P
>&#13;   <B
CLASS="function"
>db2_execute()</B
> executes an SQL statement that was
   prepared by <A
HREF="function.db2-prepare.html"
><B
CLASS="function"
>db2_prepare()</B
></A
>.
  </P
><P
>&#13;   If the SQL statement returns a result set, for example, a SELECT statement
   or a CALL to a stored procedure that returns one or more result sets, you
   can retrieve a row as an array from the <TT
CLASS="literal"
>stmt</TT
> resource
   using <A
HREF="function.db2-fetch-assoc.html"
><B
CLASS="function"
>db2_fetch_assoc()</B
></A
>,
   <A
HREF="function.db2-fetch-both.html"
><B
CLASS="function"
>db2_fetch_both()</B
></A
>, or
   <A
HREF="function.db2-fetch-array.html"
><B
CLASS="function"
>db2_fetch_array()</B
></A
>. Alternatively, you can use
   <A
HREF="function.db2-fetch-row.html"
><B
CLASS="function"
>db2_fetch_row()</B
></A
> to move the result set pointer to the
   next row and fetch a column at a time from that row with
   <A
HREF="function.db2-result.html"
><B
CLASS="function"
>db2_result()</B
></A
>.
  </P
><P
>&#13;   Refer to <A
HREF="function.db2-prepare.html"
><B
CLASS="function"
>db2_prepare()</B
></A
> for a brief discussion of the
   advantages of using <A
HREF="function.db2-prepare.html"
><B
CLASS="function"
>db2_prepare()</B
></A
> and
   <B
CLASS="function"
>db2_execute()</B
> rather than <A
HREF="function.db2-exec.html"
><B
CLASS="function"
>db2_exec()</B
></A
>.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN80640"
></A
><H2
>参数</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>stmt</CODE
></DT
><DD
><P
>&#13;       A prepared statement returned from <A
HREF="function.db2-prepare.html"
><B
CLASS="function"
>db2_prepare()</B
></A
>.
      </P
></DD
><DT
><CODE
CLASS="parameter"
>parameters</CODE
></DT
><DD
><P
>&#13;       An array of input parameters matching any parameter markers contained
       in the prepared statement.
      </P
></DD
></DL
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN80655"
></A
><H2
>返回值</H2
><P
>&#13;   如果成功则返回 <TT
CLASS="constant"
><B
>TRUE</B
></TT
>,失败则返回 <TT
CLASS="constant"
><B
>FALSE</B
></TT
>。
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN80660"
></A
><H2
>范例</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN80663"
></A
><P
><B
>例 1. Preparing and executing an SQL statement with parameter markers</B
></P
><P
>&#13;     The following example prepares an INSERT statement that accepts four
     parameter markers, then iterates over an array of arrays containing the
     input values to be passed to <B
CLASS="function"
>db2_execute()</B
>.
    </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$pet </font><font color="#007700">= array(</font><font color="#0000BB">0</font><font color="#007700">, </font><font color="#DD0000">'cat'</font><font color="#007700">, </font><font color="#DD0000">'Pook'</font><font color="#007700">, </font><font color="#0000BB">3.2</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$insert </font><font color="#007700">= </font><font color="#DD0000">'INSERT INTO animals (id, breed, name, weight)<br />&nbsp;&nbsp;&nbsp;&nbsp;VALUES (?, ?, ?, ?)'</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$stmt </font><font color="#007700">= </font><font color="#0000BB">db2_prepare</font><font color="#007700">(</font><font color="#0000BB">$conn</font><font color="#007700">, </font><font color="#0000BB">$insert</font><font color="#007700">);<br />if (</font><font color="#0000BB">$stmt</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$result </font><font color="#007700">= </font><font color="#0000BB">db2_execute</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">, </font><font color="#0000BB">$pet</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;if (</font><font color="#0000BB">$result</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print </font><font color="#DD0000">"Successfully added new pet."</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>上例将输出:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>Successfully added new pet.</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN80670"
></A
><P
><B
>例 2. Calling a stored procedure with an OUT parameter</B
></P
><P
>&#13;     The following example prepares a CALL statement that accepts one 
     parameter marker representing an OUT parameter, binds the PHP variable
     <TT
CLASS="literal"
>$my_pets</TT
> to the parameter using
     <A
HREF="function.db2-bind-param.html"
><B
CLASS="function"
>db2_bind_param()</B
></A
>, then issues
     <B
CLASS="function"
>db2_execute()</B
> to execute the CALL statement. After the
     CALL to the stored procedure has been made, the value of
     <TT
CLASS="literal"
>$num_pets</TT
> changes to reflect the value returned by the
     stored procedure for that OUT parameter.
    </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$num_pets </font><font color="#007700">= </font><font color="#0000BB">0</font><font color="#007700">;<br /></font><font color="#0000BB">$res </font><font color="#007700">= </font><font color="#0000BB">db2_prepare</font><font color="#007700">(</font><font color="#0000BB">$conn</font><font color="#007700">, </font><font color="#DD0000">"CALL count_my_pets(?)"</font><font color="#007700">);<br /></font><font color="#0000BB">$rc </font><font color="#007700">= </font><font color="#0000BB">db2_bind_param</font><font color="#007700">(</font><font color="#0000BB">$res</font><font color="#007700">, </font><font color="#0000BB">1</font><font color="#007700">, </font><font color="#DD0000">"num_pets"</font><font color="#007700">, </font><font color="#0000BB">DB2_PARAM_OUT</font><font color="#007700">);<br /></font><font color="#0000BB">$rc </font><font color="#007700">= </font><font color="#0000BB">db2_execute</font><font color="#007700">(</font><font color="#0000BB">$res</font><font color="#007700">);<br />print </font><font color="#DD0000">"I have $num_pets pets!"</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>上例将输出:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>I have 7 pets!</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN80680"
></A
><P
><B
>例 3. Returning XML data as a SQL ResultSet</B
></P
><P
>&#13;     The following example demonstrates how to work with documents stored 
     in a XML column using the SAMPLE database. Using some pretty simple 
     SQL/XML, this example returns some of the nodes in a XML document in 
     a SQL ResultSet format that most users are familiar with.
    </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />$conn </font><font color="#007700">= </font><font color="#0000BB">db2_connect</font><font color="#007700">(</font><font color="#DD0000">"SAMPLE"</font><font color="#007700">, </font><font color="#DD0000">"db2inst1"</font><font color="#007700">, </font><font color="#DD0000">"ibmdb2"</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;<br /></font><font color="#0000BB">$query </font><font color="#007700">= </font><font color="#DD0000">'SELECT * FROM XMLTABLE(<br />&nbsp;&nbsp;&nbsp;&nbsp;XMLNAMESPACES (DEFAULT \'http://posample.org\'),<br />&nbsp;&nbsp;&nbsp;&nbsp;\'db2-fn:xmlcolumn("CUSTOMER.INFO")/customerinfo\'<br />&nbsp;&nbsp;&nbsp;&nbsp;COLUMNS<br />&nbsp;&nbsp;&nbsp;&nbsp;"CID" VARCHAR (50) PATH \'@Cid\',<br />&nbsp;&nbsp;&nbsp;&nbsp;"NAME" VARCHAR (50) PATH \'name\',<br />&nbsp;&nbsp;&nbsp;&nbsp;"PHONE" VARCHAR (50) PATH \'phone [ @type = "work"]\'<br />&nbsp;&nbsp;&nbsp;&nbsp;) AS T<br />&nbsp;&nbsp;&nbsp;&nbsp;WHERE NAME = ?<br />&nbsp;&nbsp;&nbsp;&nbsp;'</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$stmt </font><font color="#007700">= </font><font color="#0000BB">db2_prepare</font><font color="#007700">(</font><font color="#0000BB">$conn</font><font color="#007700">, </font><font color="#0000BB">$query</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;<br /></font><font color="#0000BB">$name </font><font color="#007700">= </font><font color="#DD0000">'Kathy Smith'</font><font color="#007700">;<br /><br />if (</font><font color="#0000BB">$stmt</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">db2_bind_param</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">, </font><font color="#0000BB">1</font><font color="#007700">, </font><font color="#DD0000">"name"</font><font color="#007700">, </font><font color="#0000BB">DB2_PARAM_IN</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">db2_execute</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;while(</font><font color="#0000BB">$row </font><font color="#007700">= </font><font color="#0000BB">db2_fetch_object</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">)){<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">printf</font><font color="#007700">(</font><font color="#DD0000">"$row</font><font color="#007700">-&gt;</font><font color="#DD0000">CID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$row</font><font color="#007700">-&gt;</font><font color="#DD0000">NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$row</font><font color="#007700">-&gt;</font><font color="#DD0000">PHONE</font><font color="#007700">\n</font><font color="#DD0000">"</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></font><font color="#0000BB">db2_close</font><font color="#007700">(</font><font color="#0000BB">$conn</font><font color="#007700">);<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>上例将输出:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>1000     Kathy Smith     416-555-1358
1001     Kathy Smith     905-555-7258</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN80686"
></A
><P
><B
>例 4. Performing a "JOIN" with XML data</B
></P
><P
>&#13;     The following example works with documents stored in 2 different 
     XML columns in the SAMPLE database. It creates 2 temporary 
     tables from the XML documents from 2 different columns and 
     returns a SQL ResultSet with information regarding shipping 
     status for the customer.
    </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br />$conn </font><font color="#007700">= </font><font color="#0000BB">db2_connect</font><font color="#007700">(</font><font color="#DD0000">"SAMPLE"</font><font color="#007700">, </font><font color="#DD0000">"db2inst1"</font><font color="#007700">, </font><font color="#DD0000">"ibmdb2"</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$query </font><font color="#007700">= </font><font color="#DD0000">'<br />SELECT A.CID, A.NAME, A.PHONE, C.PONUM, C.STATUS<br />FROM<br />XMLTABLE(<br />XMLNAMESPACES (DEFAULT \'http://posample.org\'),<br />\'db2-fn:xmlcolumn("CUSTOMER.INFO")/customerinfo\'<br />COLUMNS<br />"CID" BIGINT PATH \'@Cid\',<br />"NAME" VARCHAR (50) PATH \'name\',<br />"PHONE" VARCHAR (50) PATH \'phone [ @type = "work"]\'<br />) as A,<br />PURCHASEORDER AS B,<br />XMLTABLE (<br />XMLNAMESPACES (DEFAULT \'http://posample.org\'),<br />\'db2-fn:xmlcolumn("PURCHASEORDER.PORDER")/PurchaseOrder\'<br />COLUMNS<br />"PONUM"&nbsp;&nbsp;BIGINT PATH \'@PoNum\',<br />"STATUS" VARCHAR (50) PATH \'@Status\'<br />) as C<br />WHERE A.CID = B.CUSTID AND<br />&nbsp;&nbsp;&nbsp;&nbsp;B.POID = C.PONUM AND<br />&nbsp;&nbsp;&nbsp;&nbsp;A.NAME = ?<br />'</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$stmt </font><font color="#007700">= </font><font color="#0000BB">db2_prepare</font><font color="#007700">(</font><font color="#0000BB">$conn</font><font color="#007700">, </font><font color="#0000BB">$query</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$name </font><font color="#007700">= </font><font color="#DD0000">'Kathy Smith'</font><font color="#007700">;<br /><br />if (</font><font color="#0000BB">$stmt</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">db2_bind_param</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">, </font><font color="#0000BB">1</font><font color="#007700">, </font><font color="#DD0000">"name"</font><font color="#007700">, </font><font color="#0000BB">DB2_PARAM_IN</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">db2_execute</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;while(</font><font color="#0000BB">$row </font><font color="#007700">= </font><font color="#0000BB">db2_fetch_object</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">)){<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">printf</font><font color="#007700">(</font><font color="#DD0000">"$row</font><font color="#007700">-&gt;</font><font color="#DD0000">CID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$row</font><font color="#007700">-&gt;</font><font color="#DD0000">NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$row</font><font color="#007700">-&gt;</font><font color="#DD0000">PHONE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$row</font><font color="#007700">-&gt;</font><font color="#DD0000">PONUM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$row</font><font color="#007700">-&gt;</font><font color="#DD0000">STATUS</font><font color="#007700">\n</font><font color="#DD0000">"</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></font><font color="#0000BB">db2_close</font><font color="#007700">(</font><font color="#0000BB">$conn</font><font color="#007700">);<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>上例将输出:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>1001     Kathy Smith     905-555-7258     5002     Shipped</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN80692"
></A
><P
><B
>例 5. Returning SQL data as part of a larger XML document</B
></P
><P
>&#13;     The following example works with a portion of the PRODUCT.DESCRIPTION 
     documents in the SAMPLE database. It creates a XML document containing 
     product description (XML data) and pricing info (SQL data).
    </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br />$conn </font><font color="#007700">= </font><font color="#0000BB">db2_connect</font><font color="#007700">(</font><font color="#DD0000">"SAMPLE"</font><font color="#007700">, </font><font color="#DD0000">"db2inst1"</font><font color="#007700">, </font><font color="#DD0000">"ibmdb2"</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$query </font><font color="#007700">= </font><font color="#DD0000">'<br />SELECT<br />XMLSERIALIZE(<br />XMLQUERY(\'<br />&nbsp;&nbsp;&nbsp;&nbsp;declare boundary-space strip;<br />&nbsp;&nbsp;&nbsp;&nbsp;declare default element namespace "http://posample.org";<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;promoList&gt; {<br />&nbsp;&nbsp;&nbsp;&nbsp;for $prod in $doc/product<br />&nbsp;&nbsp;&nbsp;&nbsp;where $prod/description/price &lt; 10.00<br />&nbsp;&nbsp;&nbsp;&nbsp;order by $prod/description/price ascending<br />&nbsp;&nbsp;&nbsp;&nbsp;return(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;promoitem&gt; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$prod,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;startdate&gt; {$start} &lt;/startdate&gt;,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;enddate&gt; {$end} &lt;/enddate&gt;,<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;promoprice&gt; {$promo} &lt;/promoprice&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &lt;/promoitem&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;)<br />&nbsp;&nbsp;&nbsp;&nbsp;} &lt;/promoList&gt;<br />\' passing by ref DESCRIPTION AS "doc",<br />PROMOSTART as "start",<br />PROMOEND as "end",<br />PROMOPRICE as "promo"<br />RETURNING SEQUENCE)<br />AS CLOB (32000))<br />AS NEW_PRODUCT_INFO<br />FROM PRODUCT<br />WHERE PID = ?<br />'</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$stmt </font><font color="#007700">= </font><font color="#0000BB">db2_prepare</font><font color="#007700">(</font><font color="#0000BB">$conn</font><font color="#007700">, </font><font color="#0000BB">$query</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$pid </font><font color="#007700">= </font><font color="#DD0000">"100-100-01"</font><font color="#007700">;<br /><br />if (</font><font color="#0000BB">$stmt</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">db2_bind_param</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">, </font><font color="#0000BB">1</font><font color="#007700">, </font><font color="#DD0000">"pid"</font><font color="#007700">, </font><font color="#0000BB">DB2_PARAM_IN</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">db2_execute</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;while(</font><font color="#0000BB">$row </font><font color="#007700">= </font><font color="#0000BB">db2_fetch_array</font><font color="#007700">(</font><font color="#0000BB">$stmt</font><font color="#007700">)){<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">printf</font><font color="#007700">(</font><font color="#DD0000">"$row</font><font color="#007700">[</font><font color="#DD0000">0</font><font color="#007700">]\n</font><font color="#DD0000">"</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></font><font color="#0000BB">db2_close</font><font color="#007700">(</font><font color="#0000BB">$conn</font><font color="#007700">);<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>上例将输出:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>&#60;promoList xmlns="http://posample.org"&#62;
    &#60;promoitem&#62;
    &#60;product pid="100-100-01"&#62;
        &#60;description&#62;
            &#60;name&#62;Snow Shovel, Basic 22 inch&#60;/name&#62;
            &#60;details&#62;Basic Snow Shovel, 22 inches wide, straight handle with D-Grip&#60;/details&#62;
            &#60;price&#62;9.99&#60;/price&#62;
            &#60;weight&#62;1 kg&#60;/weight&#62;
        &#60;/description&#62;
    &#60;/product&#62;
    &#60;startdate&#62;2004-11-19&#60;/startdate&#62;
    &#60;enddate&#62;2004-12-19&#60;/enddate&#62;
    &#60;promoprice&#62;7.25&#60;/promoprice&#62;
    &#60;/promoitem&#62;
&#60;/promoList&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN80698"
></A
><H2
>参见</H2
><P
>&#13;   <P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
><A
HREF="function.db2-exec.html"
><B
CLASS="function"
>db2_exec()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.db2-fetch-array.html"
><B
CLASS="function"
>db2_fetch_array()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.db2-fetch-assoc.html"
><B
CLASS="function"
>db2_fetch_assoc()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.db2-fetch-both.html"
><B
CLASS="function"
>db2_fetch_both()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.db2-fetch-row.html"
><B
CLASS="function"
>db2_fetch_row()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.db2-prepare.html"
><B
CLASS="function"
>db2_prepare()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.db2-result.html"
><B
CLASS="function"
>db2_result()</B
></A
></TD
></TR
></TBODY
></TABLE
><P
></P
>
  </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.db2-exec.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.db2-fetch-array.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>db2_exec</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.ibm-db2.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>db2_fetch_array</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>