<HTML ><HEAD ><TITLE >sesam_fetch_array</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Manual de PHP" HREF="index.html"><LINK REL="UP" TITLE="SESAM database functions" HREF="ref.sesam.html"><LINK REL="PREVIOUS" TITLE="sesam_execimm" HREF="function.sesam-execimm.html"><LINK REL="NEXT" TITLE="sesam_fetch_result" HREF="function.sesam-fetch-result.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" >Manual de PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.sesam-execimm.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-fetch-result.html" ACCESSKEY="N" >Siguiente</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.sesam-fetch-array" ></A >sesam_fetch_array</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN69180" ></A ><P > (PHP 3 CVS only)</P >sesam_fetch_array -- Fetch one row as an associative array</DIV ><DIV CLASS="refsect1" ><A NAME="AEN69183" ></A ><H2 >Description</H2 >array <B CLASS="methodname" >sesam_fetch_array</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 > <B CLASS="function" >sesam_fetch_array()</B > is an alternative version of <A HREF="function.sesam-fetch-row.html" ><B CLASS="function" >sesam_fetch_row()</B ></A >. Instead of storing the data in the numeric indices of the result array, it stores the data in associative indices, using the field names as keys. </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 > For the valid values of the optional <TT CLASS="parameter" ><I >whence</I ></TT >and <TT CLASS="parameter" ><I >offset</I ></TT > parameters, see the <A HREF="function.sesam-fetch-row.html" ><B CLASS="function" >sesam_fetch_row()</B ></A > function for details. </P ><P > <B CLASS="function" >sesam_fetch_array()</B > fetches one row of data from the result associated with the specified result identifier. The row is returned as an associative array. Each result column is stored with an associative index equal to its column (aka. field) name. The column names are converted to lower case. </P ><P > Columns without a field name (e.g., results of arithmetic operations) and empty fields are not stored in the array. Also, if two or more columns of the result have the same column names, the later column will take precedence. In this situation, either call <A HREF="function.sesam-fetch-row.html" ><B CLASS="function" >sesam_fetch_row()</B ></A > or make an alias for the column. <DIV CLASS="informalexample" ><A NAME="AEN69213" ></A ><P ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="programlisting" >SELECT TBL1.COL AS FOO, TBL2.COL AS BAR FROM TBL1, TBL2</PRE ></TD ></TR ></TABLE ><P ></P ></DIV > </P ><P > A special handling allows fetching "multiple field" columns (which would otherwise all have the same column names). For each column of a "multiple field", the index name is constructed by appending the string "(n)" where n is the sub-index of the multiple field column, ranging from 1 to its declared repetition factor. The indices are NOT zero based, in order to match the nomenclature used in the respective query syntax. For a column declared as: <DIV CLASS="informalexample" ><A NAME="AEN69216" ></A ><P ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="sesam" >CREATE TABLE ... ( ... MULTI(3) INT )</PRE ></TD ></TR ></TABLE ><P ></P ></DIV > the associative indices used for the individual "multiple field" columns would be <TT CLASS="literal" >"multi(1)"</TT >, <TT CLASS="literal" >"multi(2)"</TT >, and <TT CLASS="literal" >"multi(3)"</TT > respectively. </P ><P > Subsequent calls to <B CLASS="function" >sesam_fetch_array()</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="AEN69224" ></A ><P ><B >Ejemplo 1. SESAM fetch array</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: print "<TABLE BORDER>\n"; while (($row = sesam_fetch_array ($result)) && count ($row) > 0) { print " <TR>\n"; print " <TD>".htmlspecialchars ($row["firstname"])."</TD>\n"; print " <TD>".htmlspecialchars ($row["lastname"])."</TD>\n"; print " <TD>".htmlspecialchars ($row["phoneno"])."</TD>\n"; print " </TR>\n"; } print "</TABLE>\n"; sesam_free_result ($result); ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ><P > See also: <A HREF="function.sesam-fetch-row.html" ><B CLASS="function" >sesam_fetch_row()</B ></A > which returns an indexed array. </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-execimm.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Inicio</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.sesam-fetch-result.html" ACCESSKEY="N" >Siguiente</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >sesam_execimm</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.sesam.html" ACCESSKEY="U" >Subir</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >sesam_fetch_result</TD ></TR ></TABLE ></DIV ></BODY ></HTML >