<HTML ><HEAD ><TITLE >fbsql_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="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=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.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" >Siguiente</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="AEN18333" ></A ><P > (PHP 4 >= 4.0.6)</P >fbsql_query -- Send a FrontBase query</DIV ><DIV CLASS="refsect1" ><A NAME="AEN18336" ></A ><H2 >Description</H2 >resource <B CLASS="methodname" >fbsql_query</B > ( string query [, resource link_identifier])<BR ></BR ><P > <B CLASS="function" >fbsql_query()</B > sends a query to the currently active database on the server that's associated with the specified link identifier. If <TT CLASS="parameter" ><I >link_identifier</I ></TT > isn't specified, the last opened link is assumed. If no link is open, the function tries to establish a link as if <A HREF="function.fbsql-connect.html" ><B CLASS="function" >fbsql_connect()</B ></A > was called with no arguments, and use it. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Nota: </B > The query string shall always end with a semicolon. </P ></BLOCKQUOTE ></DIV ><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 > 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="AEN18361" ></A ><P ><B >Ejemplo 1. <B CLASS="function" >fbsql_query()</B > example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php $result = fbsql_query ("SELECT * WHERE 1=1") or die ("Invalid query"); ?></PRE ></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="AEN18370" ></A ><P ><B >Ejemplo 2. <B CLASS="function" >fbsql_query()</B > example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php $result = fbsql_query ("SELECT my_col FROM my_tbl") or die ("Invalid query"); ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </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 ><P > Assuming 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 ><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 >. When you are done with the result set, you can free the resources associated with it by calling <A HREF="function.fbsql-free-result.html" ><B CLASS="function" >fbsql_free_result()</B ></A >. Although, the memory will automatically be freed at the end of the script's execution. </P ><P > See also: <A HREF="function.fbsql-affected-rows.html" ><B CLASS="function" >fbsql_affected_rows()</B ></A >, <A HREF="function.fbsql-db-query.html" ><B CLASS="function" >fbsql_db_query()</B ></A >, <A HREF="function.fbsql-free-result.html" ><B CLASS="function" >fbsql_free_result()</B ></A >, <A HREF="function.fbsql-result.html" ><B CLASS="function" >fbsql_result()</B ></A >, <A HREF="function.fbsql-select-db.html" ><B CLASS="function" >fbsql_select_db()</B ></A >, and <A HREF="function.fbsql-connect.html" ><B CLASS="function" >fbsql_connect()</B ></A >. </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" >Inicio</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.fbsql-read-blob.html" ACCESSKEY="N" >Siguiente</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" >Subir</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >fbsql_read_blob</TD ></TR ></TABLE ></DIV ></BODY ></HTML >