Sophie

Sophie

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

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

<HTML
><HEAD
><TITLE
>sesam_query</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_num_fields"
HREF="function.sesam-num-fields.html"><LINK
REL="NEXT"
TITLE="sesam_rollback"
HREF="function.sesam-rollback.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-num-fields.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-rollback.html"
ACCESSKEY="N"
>Siguiente</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.sesam-query"
></A
>sesam_query</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN69550"
></A
><P
>    (PHP 3 CVS only)</P
>sesam_query&nbsp;--&nbsp;Perform a SESAM SQL query and prepare the result</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN69553"
></A
><H2
>Description</H2
>string <B
CLASS="methodname"
>sesam_query</B
> ( string query [, bool scrollable])<BR
></BR
><P
>&#13;     Returns: A SESAM "result identifier" on success, or
     <TT
CLASS="constant"
><B
>FALSE</B
></TT
> on error.
    </P
><P
>&#13;     A "result_id" resource is used by other functions to retrieve the
     query results.
    </P
><P
>&#13;     <B
CLASS="function"
>sesam_query()</B
> sends a query to the currently
     active database on the server. It can execute both "immediate"
     SQL statements and "select type" queries. If an "immediate"
     statement is executed, then no cursor is allocated, and any
     subsequent <A
HREF="function.sesam-fetch-row.html"
><B
CLASS="function"
>sesam_fetch_row()</B
></A
> or
     <A
HREF="function.sesam-fetch-result.html"
><B
CLASS="function"
>sesam_fetch_result()</B
></A
> call will return an empty
     result (zero columns, indicating end-of-result).  For "select
     type" statements, a result descriptor and a (scrollable or
     sequential, depending on the optional boolean
     <TT
CLASS="parameter"
><I
>scrollable</I
></TT
> parameter) cursor will be
     allocated. If <TT
CLASS="parameter"
><I
>scrollable</I
></TT
> is omitted, the
     cursor will be sequential.
    </P
><P
>&#13;     When using "scrollable" cursors, the cursor can be freely
     positioned on the result set. For each "scrollable" query, there
     are global default values for the scrolling type (initialized to:
     <TT
CLASS="literal"
>SESAM_SEEK_NEXT</TT
>) and the scrolling offset
     which can either be set once by
     <A
HREF="function.sesam-seek-row.html"
><B
CLASS="function"
>sesam_seek_row()</B
></A
> or each time when fetching a
     row using <A
HREF="function.sesam-fetch-row.html"
><B
CLASS="function"
>sesam_fetch_row()</B
></A
>.
    </P
><P
>&#13;     For "immediate" statements, the number of affected rows is saved
     for retrieval by the <A
HREF="function.sesam-affected-rows.html"
><B
CLASS="function"
>sesam_affected_rows()</B
></A
>
     function.
    </P
><P
>&#13;     See also: <A
HREF="function.sesam-fetch-row.html"
><B
CLASS="function"
>sesam_fetch_row()</B
></A
> and
     <A
HREF="function.sesam-fetch-result.html"
><B
CLASS="function"
>sesam_fetch_result()</B
></A
>.
     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN69582"
></A
><P
><B
>Ejemplo 1. 
       Show all rows of the "phone" table as a html table
      </B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>&#60;?php
if (!sesam_connect ("phonedb", "demo", "otto"))
    die ("cannot connect");
$result = sesam_query ("select * from phone");
if (!$result) {
    $err = sesam_diagnostic();
    die ($err["errmsg"]);
}
echo "&#60;TABLE BORDER&#62;\n";
// Add title header with column names above the result:
if ($cols = sesam_field_array ($result)) {
    echo " &#60;TR&#62;&#60;TH COLSPAN=".$cols["count"]."&#62;Result:&#60;/TH&#62;&#60;/TR&#62;\n";
    echo " &#60;TR&#62;\n";
    for ($col = 0; $col &#60; $cols["count"]; ++$col) {
        $colattr = $cols[$col];
        /* Span the table head over SESAM's "Multiple Fields": */
        if ($colattr["count"] &#62; 1) {
            echo "  &#60;TH COLSPAN=".$colattr["count"]."&#62;".$colattr["name"].
                "(1..".$colattr["count"].")&#60;/TH&#62;\n";
            $col += $colattr["count"] - 1;
        } else
            echo "  &#60;TH&#62;" . $colattr["name"] . "&#60;/TH&#62;\n";
    }
    echo " &#60;/TR&#62;\n";
}

do {
    // Fetch the result in chunks of 100 rows max.
    $ok = sesam_fetch_result ($result, 100);
    for ($row=0; $row &#60; $ok["rows"]; ++$row) {
        echo " &#60;TR&#62;\n";
        for ($col = 0; $col &#60; $ok["cols"]; ++$col) {
            if (isset($ok[$col][$row]))
                echo "  &#60;TD&#62;" . $ok[$col][$row] . "&#60;/TD&#62;\n";
            } else {
                echo "  &#60;TD&#62;-empty-&#60;/TD&#62;\n";
            }
        }
        echo " &#60;/TR&#62;\n";
    }
} 
while ($ok["truncated"]) { // while there may be more data
    echo "&#60;/TABLE&#62;\n";
}
// free result id
sesam_free_result($result);
?&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </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-num-fields.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-rollback.html"
ACCESSKEY="N"
>Siguiente</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>sesam_num_fields</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_rollback</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>