Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > a34ed6838d4b29d38abd504392a4a797 > files > 2395

php-manual-es-4.3.0-2mdk.noarch.rpm

<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&nbsp;--&nbsp;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
>&#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
><P
>&#13;     <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
>&#13;     <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
>&#13;     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
>&#13;     <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
>&#13;     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
>&#13;     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
>&#13;     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"
>&#60;?php
$result = sesam_query ("SELECT * FROM phone\n".
                       "  WHERE LASTNAME='".strtoupper($name)."'\n".
                       "  ORDER BY FIRSTNAME", 1);
if (!$result) {
    ... error ...
}
// print the table:
print "&#60;TABLE BORDER&#62;\n";
while (($row = sesam_fetch_array ($result)) &#38;&#38; count ($row) &#62; 0) {
    print " &#60;TR&#62;\n";
    print " &#60;TD&#62;".htmlspecialchars ($row["firstname"])."&#60;/TD&#62;\n";
    print " &#60;TD&#62;".htmlspecialchars ($row["lastname"])."&#60;/TD&#62;\n";
    print " &#60;TD&#62;".htmlspecialchars ($row["phoneno"])."&#60;/TD&#62;\n";
    print " &#60;/TR&#62;\n";
}
print "&#60;/TABLE&#62;\n";
sesam_free_result ($result);
?&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><P
>&#13;     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
>