<HTML ><HEAD ><TITLE >sesam_fetch_row</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" 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=ISO-8859-1"></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 Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.sesam-fetch-result.html" ACCESSKEY="P" >Prev</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" >Next</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="AEN83389" ></A ><P > (PHP 3 CVS only)</P >sesam_fetch_row -- Fetch one row as an array</DIV ><DIV CLASS="refsect1" ><A NAME="AEN83392" ></A ><H2 >Description</H2 >array <B CLASS="methodname" >sesam_fetch_row</B > ( string result_id [, int whence [, int offset]])<BR ></BR ><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 ><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 > <TT CLASS="parameter" ><I >result_id</I ></TT > is a valid result id returned by <A HREF="function.sesam-query.html" ><B CLASS="function" >sesam_query()</B ></A > (select type queries only!). </P ><P > <TT CLASS="parameter" ><I >whence</I ></TT > 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="AEN83416" ></A ><P ><B >Table 1. Valid values for <TT CLASS="parameter" ><I >"whence"</I ></TT > parameter</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><THEAD ><TR ><TH ALIGN="LEFT" VALIGN="MIDDLE" >Value</TH ><TH ALIGN="LEFT" VALIGN="MIDDLE" >Constant</TH ><TH ALIGN="LEFT" VALIGN="MIDDLE" >Meaning</TH ></TR ></THEAD ><TBODY ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >0</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="literal" >SESAM_SEEK_NEXT</TT ></TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > read sequentially (after fetch, the internal default is set to <TT CLASS="literal" >SESAM_SEEK_NEXT</TT >) </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >1</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="literal" >SESAM_SEEK_PRIOR</TT ></TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > read sequentially backwards (after fetch, the internal default is set to <TT CLASS="literal" >SESAM_SEEK_PRIOR</TT >) </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >2</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="literal" >SESAM_SEEK_FIRST</TT ></TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > rewind to first row (after fetch, the default is set to <TT CLASS="literal" >SESAM_SEEK_NEXT</TT >) </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >3</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="literal" >SESAM_SEEK_LAST</TT ></TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > seek to last row (after fetch, the default is set to <TT CLASS="literal" >SESAM_SEEK_PRIOR</TT >) </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >4</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="literal" >SESAM_SEEK_ABSOLUTE</TT ></TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > seek to absolute row number given as <TT CLASS="parameter" ><I >offset</I ></TT > (Zero-based. After fetch, the internal default is set to <TT CLASS="literal" >SESAM_SEEK_ABSOLUTE</TT >, and the internal offset value is auto-incremented) </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >5</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="literal" >SESAM_SEEK_RELATIVE</TT ></TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" > seek relative to current scroll position, where <TT CLASS="parameter" ><I >offset</I ></TT > 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 <TT CLASS="parameter" ><I >whence</I ></TT > parameter is omitted, the global default values for the scrolling type (initialized to: <TT CLASS="literal" >SESAM_SEEK_NEXT</TT >, and settable by <A HREF="function.sesam-seek-row.html" ><B CLASS="function" >sesam_seek_row()</B ></A >) are used. If <TT CLASS="parameter" ><I >whence</I ></TT > is supplied, its value replaces the global default. </P ><P > <TT CLASS="parameter" ><I >offset</I ></TT > is an optional parameter which is only evaluated (and required) if <TT CLASS="parameter" ><I >whence</I ></TT > is either <TT CLASS="literal" >SESAM_SEEK_RELATIVE</TT > or <TT CLASS="literal" >SESAM_SEEK_ABSOLUTE</TT >. This parameter is only valid for "scrollable" cursors. </P ><P > <B CLASS="function" >sesam_fetch_row()</B > 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 php <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 > 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 ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN83482" ></A ><P ><B >Example 1. SESAM fetch rows</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php $result = sesam_query ("SELECT * FROM phone\n". " WHERE LASTNAME='".strtoupper($name)."'\n". " ORDER BY FIRSTNAME", 1); if (!$result) { ... error ... } // print the table in backward order print "<TABLE BORDER>\n"; $row = sesam_fetch_row ($result, SESAM_SEEK_LAST); while (is_array ($row)) { print " <TR>\n"; for ($col = 0; $col < $row["count"]; ++$col) { print " <TD>".htmlspecialchars ($row[$col])."</TD>\n"; } print " </TR>\n"; // use implied SESAM_SEEK_PRIOR $row = sesam_fetch_row ($result); } print "</TABLE>\n"; sesam_free_result ($result); ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ><P > See also: <A HREF="function.sesam-fetch-array.html" ><B CLASS="function" >sesam_fetch_array()</B ></A > which returns an associative array, and <A HREF="function.sesam-fetch-result.html" ><B CLASS="function" >sesam_fetch_result()</B ></A > which returns many rows per invocation. </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" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.sesam-field-array.html" ACCESSKEY="N" >Next</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" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >sesam_field_array</TD ></TR ></TABLE ></DIV ></BODY ></HTML >