<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >fbsql_query</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="FrontBase Functions" HREF="ref.fbsql.html"><LINK REL="PREVIOUS" TITLE="fbsql_pconnect" HREF="function.fbsql-pconnect.html"><LINK REL="NEXT" TITLE="fbsql_read_blob" HREF="function.fbsql-read-blob.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.fbsql-pconnect.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.fbsql-read-blob.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.fbsql-query" ></A >fbsql_query</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN55981" ></A ><P > (PHP 4 >= 4.0.6, PHP 5)</P >fbsql_query -- Send a FrontBase query</DIV ><DIV CLASS="refsect1" ><A NAME="AEN55984" ></A ><H2 >Descrição</H2 >resource <B CLASS="methodname" >fbsql_query</B > ( string query [, resource link_identifier [, int batch_size]] )<BR ></BR ><P > Sends a <CODE CLASS="parameter" >query</CODE > to the currently active database on the server. </P ><P > If the query succeeds, you can call <A HREF="function.fbsql-num-rows.html" ><B CLASS="function" >fbsql_num_rows()</B ></A > to find out how many rows were returned for a SELECT statement or <A HREF="function.fbsql-affected-rows.html" ><B CLASS="function" >fbsql_affected_rows()</B ></A > to find out how many rows were affected by a DELETE, INSERT, REPLACE, or UPDATE statement. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN56003" ></A ><H2 >Parâmetros</H2 ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><CODE CLASS="parameter" >query</CODE ></DT ><DD ><P > The SQL query to be executed. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Nota: </B > The query string shall always end with a semicolon. </P ></BLOCKQUOTE ></DIV ></DD ><DT ><CODE CLASS="parameter" > link_identifier</CODE ></DT ><DD ><P >Um identificador de conexão FrontBase retornado por <A HREF="function.fbsql-connect.html" ><B CLASS="function" >fbsql_connect()</B ></A > ou <A HREF="function.fbsql-pconnect.html" ><B CLASS="function" >fbsql_pconnect()</B ></A >.</P ><P >Se opcional e não especificado, a função tentará encontrar uma conexão aberta para o servidor FrontBase server e se não for encontrada uma conexão dessa ela irá tentar criar uma como se <A HREF="function.fbsql-connect.html" ><B CLASS="function" >fbsql_connect()</B ></A > fosse chamada sem argumentos</P ></DD ><DT ><CODE CLASS="parameter" >batch_size</CODE ></DT ><DD ><P > </P ></DD ></DL ></DIV > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN56028" ></A ><H2 >Valores de retornado</H2 ><P > <B CLASS="function" >fbsql_query()</B > returns <TT CLASS="constant" ><B >TRUE</B ></TT > (non-zero) or <TT CLASS="constant" ><B >FALSE</B ></TT > to indicate whether or not the query succeeded. A return value of <TT CLASS="constant" ><B >TRUE</B ></TT > means that the query was legal and could be executed by the server. It does not indicate anything about the number of rows affected or returned. It is perfectly possible for a query to succeed but affect no rows or return no rows. </P ><P > For SELECT statements, <B CLASS="function" >fbsql_query()</B > returns a new result identifier that you can pass to <A HREF="function.fbsql-result.html" ><B CLASS="function" >fbsql_result()</B ></A >. </P ><P > <B CLASS="function" >fbsql_query()</B > will also fail and return <TT CLASS="constant" ><B >FALSE</B ></TT > if you don't have permission to access the table(s) referenced by the query. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN56041" ></A ><H2 >Exemplos</H2 ><P > The following query is syntactically invalid, so <B CLASS="function" >fbsql_query()</B > fails and returns <TT CLASS="constant" ><B >FALSE</B ></TT >: <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN56046" ></A ><P ><B >Exemplo 1. <B CLASS="function" >fbsql_query()</B > example</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">fbsql_query</font><font color="#007700">(</font><font color="#DD0000">"SELECT * WHERE 1=1"</font><font color="#007700">)<br /> or die (</font><font color="#DD0000">"Invalid query"</font><font color="#007700">);<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > The following query is semantically invalid if <TT CLASS="literal" >my_col</TT > is not a column in the table <TT CLASS="literal" >my_tbl</TT >, so <B CLASS="function" >fbsql_query()</B > fails and returns <TT CLASS="constant" ><B >FALSE</B ></TT >: <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN56055" ></A ><P ><B >Exemplo 2. <B CLASS="function" >fbsql_query()</B > example</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">fbsql_query </font><font color="#007700">(</font><font color="#DD0000">"SELECT my_col FROM my_tbl;"</font><font color="#007700">)<br /> or die (</font><font color="#DD0000">"Invalid query"</font><font color="#007700">);<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN56059" ></A ><H2 >Veja também</H2 ><P > <P ></P ><TABLE BORDER="0" ><TBODY ><TR ><TD ><A HREF="function.fbsql-affected-rows.html" ><B CLASS="function" >fbsql_affected_rows()</B ></A ></TD ></TR ><TR ><TD ><A HREF="function.fbsql-db-query.html" ><B CLASS="function" >fbsql_db_query()</B ></A ></TD ></TR ><TR ><TD ><A HREF="function.fbsql-free-result.html" ><B CLASS="function" >fbsql_free_result()</B ></A ></TD ></TR ><TR ><TD ><A HREF="function.fbsql-result.html" ><B CLASS="function" >fbsql_result()</B ></A ></TD ></TR ><TR ><TD ><A HREF="function.fbsql-select-db.html" ><B CLASS="function" >fbsql_select_db()</B ></A ></TD ></TR ><TR ><TD ><A HREF="function.fbsql-connect.html" ><B CLASS="function" >fbsql_connect()</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.fbsql-pconnect.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.fbsql-read-blob.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >fbsql_pconnect</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.fbsql.html" ACCESSKEY="U" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >fbsql_read_blob</TD ></TR ></TABLE ></DIV ></BODY ></HTML >