<!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="Manual do 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" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.sesam-fetch-result.html" ACCESSKEY="P" >Anterior</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" >Próxima</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="AEN202141" ></A ><P > (PHP 3 CVS only)</P >sesam_fetch_row -- Fetch one row as an array</DIV ><DIV CLASS="refsect1" ><A NAME="AEN202144" ></A ><H2 >Descrição</H2 >array <B CLASS="methodname" >sesam_fetch_row</B > ( string result_id [, int whence [, int offset]] )<BR ></BR ><P > 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 > 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 > 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="AEN202169" ></A ><H2 >Parâmetros</H2 ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><CODE CLASS="parameter" >result_id</CODE ></DT ><DD ><P > 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 > <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="AEN202185" ></A ><P ><B >Tabela 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 > 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 > 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 > 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 > 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 > 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 > 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 > 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 > 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="AEN202245" ></A ><H2 >Valores de retornado</H2 ><P > 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="AEN202249" ></A ><H2 >Exemplos</H2 ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN202251" ></A ><P ><B >Exemplo 1. SESAM fetch rows</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?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 /> </font><font color="#DD0000">" 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 /> </font><font color="#DD0000">" 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 /> </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">"<table border=\"1\">\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 /> echo </font><font color="#DD0000">"<tr>\n"</font><font color="#007700">;<br /> 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">< </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 /> echo </font><font color="#DD0000">"<td>" </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">"</td>\n"</font><font color="#007700">;<br /> }<br /> echo </font><font color="#DD0000">"</tr>\n"</font><font color="#007700">;<br /> </font><font color="#FF8000">// use implied SESAM_SEEK_PRIOR<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">);<br />}<br />echo </font><font color="#DD0000">"</table>\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">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN202254" ></A ><H2 >Veja também</H2 ><P > <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" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.sesam-field-array.html" ACCESSKEY="N" >Próxima</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" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >sesam_field_array</TD ></TR ></TABLE ></DIV ></BODY ></HTML >