Sophie

Sophie

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

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
>sesam_fetch_row</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="SESAM Database Functions"
HREF="ref.sesam.html"><LINK
REL="PREVIOUS"
TITLE="sesam_fetch_result"
HREF="function.sesam-fetch-result.html"><LINK
REL="NEXT"
TITLE="sesam_field_array"
HREF="function.sesam-field-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.sesam-fetch-result.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.sesam-field-array.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.sesam-fetch-row"
></A
>sesam_fetch_row</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN206788"
></A
><P
>    (PHP 3 CVS only)</P
>sesam_fetch_row&nbsp;--&nbsp;Fetch one row as an array</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN206791"
></A
><H2
>说明</H2
>array <B
CLASS="methodname"
>sesam_fetch_row</B
> ( string result_id [, int whence [, int offset]] )<BR
></BR
><P
>&#13;   Fetches one row of data from the result associated with the specified
   result identifier.  The row is returned as an array (indexed by values
   between <TT
CLASS="literal"
>0</TT
> and <TT
CLASS="literal"
>$array["count"]-1</TT
>).
   Fields may be empty, so you must check for the existence of a field by
   using the <A
HREF="function.isset.html"
><B
CLASS="function"
>isset()</B
></A
> function. The type of the returned
   fields depend on the respective SQL type declared for its column (see
   <A
HREF="ref.sesam.html"
>SESAM overview</A
> for the conversions
   applied). SESAM "multiple fields" are "inlined" and treated like a
   sequence of columns.
  </P
><P
>&#13;   The number of columns in the result set is returned in an associative
   array element $array["count"]. Because some of the result columns may be
   empty, the <A
HREF="function.count.html"
><B
CLASS="function"
>count()</B
></A
> function can not be used on the
   result row returned by <B
CLASS="function"
>sesam_fetch_row()</B
>.
  </P
><P
>&#13;   Subsequent calls to <B
CLASS="function"
>sesam_fetch_row()</B
> would return the
   next (or prior, or n'th next/prior, depending on the scroll attributes)
   row in the result set, or <TT
CLASS="constant"
><B
>FALSE</B
></TT
> if there are no more rows.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN206816"
></A
><H2
>参数</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>result_id</CODE
></DT
><DD
><P
>&#13;       A valid result id returned by <A
HREF="function.sesam-query.html"
><B
CLASS="function"
>sesam_query()</B
></A
>.
      </P
></DD
><DT
><CODE
CLASS="parameter"
>whence</CODE
></DT
><DD
><P
>&#13;       <CODE
CLASS="parameter"
>whence</CODE
> is an optional
       parameter for a fetch operation on "scrollable" cursors, which
       can be set to the following predefined constants:
       <DIV
CLASS="table"
><A
NAME="AEN206832"
></A
><P
><B
>表 1. Valid values for <CODE
CLASS="parameter"
>"whence"</CODE
> parameter</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><COL><THEAD
><TR
><TH
>Value</TH
><TH
>Constant</TH
><TH
>Meaning</TH
></TR
></THEAD
><TBODY
><TR
><TD
>0</TD
><TD
><TT
CLASS="constant"
><B
>SESAM_SEEK_NEXT</B
></TT
></TD
><TD
>&#13;            read sequentially (after fetch, the internal default is set
            to <TT
CLASS="constant"
><B
>SESAM_SEEK_NEXT</B
></TT
>)
           </TD
></TR
><TR
><TD
>1</TD
><TD
><TT
CLASS="constant"
><B
>SESAM_SEEK_PRIOR</B
></TT
></TD
><TD
>&#13;            read sequentially backwards (after fetch, the internal
            default is set to <TT
CLASS="constant"
><B
>SESAM_SEEK_PRIOR</B
></TT
>)
           </TD
></TR
><TR
><TD
>2</TD
><TD
><TT
CLASS="constant"
><B
>SESAM_SEEK_FIRST</B
></TT
></TD
><TD
>&#13;            rewind to first row (after fetch, the default is set to
            <TT
CLASS="constant"
><B
>SESAM_SEEK_NEXT</B
></TT
>)
           </TD
></TR
><TR
><TD
>3</TD
><TD
><TT
CLASS="constant"
><B
>SESAM_SEEK_LAST</B
></TT
></TD
><TD
>&#13;            seek to last row (after fetch, the default is set to
            <TT
CLASS="constant"
><B
>SESAM_SEEK_PRIOR</B
></TT
>)
           </TD
></TR
><TR
><TD
>4</TD
><TD
><TT
CLASS="constant"
><B
>SESAM_SEEK_ABSOLUTE</B
></TT
></TD
><TD
>&#13;            seek to absolute row number given as
            <CODE
CLASS="parameter"
>offset</CODE
> (Zero-based. After fetch, the
            internal default is set to
            <TT
CLASS="constant"
><B
>SESAM_SEEK_ABSOLUTE</B
></TT
>, and the internal
            offset value is auto-incremented)
           </TD
></TR
><TR
><TD
>5</TD
><TD
><TT
CLASS="constant"
><B
>SESAM_SEEK_RELATIVE</B
></TT
></TD
><TD
>&#13;            seek relative to current scroll position, where
            <CODE
CLASS="parameter"
>offset</CODE
> can be a positive or negative
            offset value.
           </TD
></TR
></TBODY
></TABLE
></DIV
>
       This parameter is only valid for "scrollable" cursors.
      </P
><P
>&#13;       When using "scrollable" cursors, the cursor can be freely positioned
       on the result set. If the <CODE
CLASS="parameter"
>whence</CODE
> parameter is
       omitted, the global default values for the scrolling type (initialized
       to: <TT
CLASS="constant"
><B
>SESAM_SEEK_NEXT</B
></TT
>, and settable by
       <A
HREF="function.sesam-seek-row.html"
><B
CLASS="function"
>sesam_seek_row()</B
></A
>) are used. If
       <CODE
CLASS="parameter"
>whence</CODE
> is supplied, its value replaces the
       global default.
      </P
></DD
><DT
><CODE
CLASS="parameter"
>offset</CODE
></DT
><DD
><P
>&#13;       Only evaluated (and required) if <CODE
CLASS="parameter"
>whence</CODE
> is
       either <TT
CLASS="constant"
><B
>SESAM_SEEK_RELATIVE</B
></TT
> or
       <TT
CLASS="constant"
><B
>SESAM_SEEK_ABSOLUTE</B
></TT
>. This parameter is only
       valid for "scrollable" cursors.
      </P
></DD
></DL
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN206892"
></A
><H2
>返回值</H2
><P
>&#13;   Returns an array that corresponds to the fetched row, or
   <TT
CLASS="constant"
><B
>FALSE</B
></TT
> if there are no more rows.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN206896"
></A
><H2
>范例</H2
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN206898"
></A
><P
><B
>例 1. SESAM fetch rows</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$result </font><font color="#007700">= </font><font color="#0000BB">sesam_query</font><font color="#007700">(</font><font color="#DD0000">"SELECT * FROM phone\n" </font><font color="#007700">.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">"&nbsp;&nbsp;WHERE LASTNAME='" </font><font color="#007700">. </font><font color="#0000BB">strtoupper</font><font color="#007700">(</font><font color="#0000BB">$name</font><font color="#007700">) . </font><font color="#DD0000">"'\n" </font><font color="#007700">.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">"&nbsp;&nbsp;ORDER BY FIRSTNAME"</font><font color="#007700">, </font><font color="#0000BB">1</font><font color="#007700">);<br />if (!</font><font color="#0000BB">$result</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">/* ... error ... */<br /></font><font color="#007700">}<br /></font><font color="#FF8000">// print the table in backward order<br /></font><font color="#007700">echo </font><font color="#DD0000">"&lt;table border=\"1\"&gt;\n"</font><font color="#007700">;<br /></font><font color="#0000BB">$row </font><font color="#007700">= </font><font color="#0000BB">sesam_fetch_row</font><font color="#007700">(</font><font color="#0000BB">$result</font><font color="#007700">, </font><font color="#0000BB">SESAM_SEEK_LAST</font><font color="#007700">);<br />while (</font><font color="#0000BB">is_array</font><font color="#007700">(</font><font color="#0000BB">$row</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"&lt;tr&gt;\n"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;for (</font><font color="#0000BB">$col </font><font color="#007700">= </font><font color="#0000BB">0</font><font color="#007700">; </font><font color="#0000BB">$col </font><font color="#007700">&lt; </font><font color="#0000BB">$row</font><font color="#007700">[</font><font color="#DD0000">"count"</font><font color="#007700">]; ++</font><font color="#0000BB">$col</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"&lt;td&gt;" </font><font color="#007700">. </font><font color="#0000BB">htmlspecialchars</font><font color="#007700">(</font><font color="#0000BB">$row</font><font color="#007700">[</font><font color="#0000BB">$col</font><font color="#007700">]) . </font><font color="#DD0000">"&lt;/td&gt;\n"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"&lt;/tr&gt;\n"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// use implied SESAM_SEEK_PRIOR<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$row </font><font color="#007700">= </font><font color="#0000BB">sesam_fetch_row</font><font color="#007700">(</font><font color="#0000BB">$result</font><font color="#007700">);<br />}<br />echo </font><font color="#DD0000">"&lt;/table&gt;\n"</font><font color="#007700">;<br /></font><font color="#0000BB">sesam_free_result</font><font color="#007700">(</font><font color="#0000BB">$result</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN206901"
></A
><H2
>参见</H2
><P
>&#13;   <P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
><A
HREF="function.sesam-fetch-array.html"
><B
CLASS="function"
>sesam_fetch_array()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.sesam-fetch-result.html"
><B
CLASS="function"
>sesam_fetch_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.sesam-fetch-result.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.sesam-field-array.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>sesam_fetch_result</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.sesam.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>sesam_field_array</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>