<HTML ><HEAD ><TITLE >ifx_prepare</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Informix functions" HREF="ref.ifx.html"><LINK REL="PREVIOUS" TITLE="ifx_pconnect" HREF="function.ifx-pconnect.html"><LINK REL="NEXT" TITLE="ifx_query" HREF="function.ifx-query.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" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.ifx-pconnect.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.ifx-query.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.ifx-prepare" ></A >ifx_prepare</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN40019" ></A ><P > (PHP 3>= 3.0.4, PHP 4 )</P >ifx_prepare -- Prepare an SQL-statement for execution</DIV ><DIV CLASS="refsect1" ><A NAME="AEN40022" ></A ><H2 >Description</H2 >int <B CLASS="methodname" >ifx_prepare</B > ( string query, int conn_id [, int cursor_def, mixed blobidarray])<BR ></BR ><P > Returns a integer <TT CLASS="parameter" ><I >result_id</I ></TT > for use by <A HREF="function.ifx-do.html" ><B CLASS="function" >ifx_do()</B ></A >. Sets <TT CLASS="parameter" ><I >affected_rows</I ></TT > for retrieval by the <A HREF="function.ifx-affected-rows.html" ><B CLASS="function" >ifx_affected_rows()</B ></A > function. </P ><P > Prepares <TT CLASS="parameter" ><I >query</I ></TT > on connection <TT CLASS="parameter" ><I >conn_id</I ></TT >. For "select-type" queries a cursor is declared and opened. The optional <TT CLASS="parameter" ><I >cursor_type</I ></TT > parameter allows you to make this a "scroll" and/or "hold" cursor. It's a bitmask and can be either IFX_SCROLL, IFX_HOLD, or both or'ed together. </P ><P > For either query type the estimated number of affected rows is saved for retrieval by <A HREF="function.ifx-affected-rows.html" ><B CLASS="function" >ifx_affected_rows()</B ></A >. </P ><P > If you have BLOB (BYTE or TEXT) columns in the query, you can add a <TT CLASS="parameter" ><I >blobidarray</I ></TT > parameter containing the corresponding "blob ids", and you should replace those columns with a "?" in the query text. </P ><P > If the contents of the TEXT (or BYTE) column allow it, you can also use "ifx_textasvarchar(1)" and "ifx_byteasvarchar(1)". This allows you to treat TEXT (or BYTE) columns just as if they were ordinary (but long) VARCHAR columns for select queries, and you don't need to bother with blob id's. </P ><P > With ifx_textasvarchar(0) or ifx_byteasvarchar(0) (the default situation), select queries will return BLOB columns as blob id's (integer value). You can get the value of the blob as a string or file with the blob functions (see below). </P ><P > See also: <A HREF="function.ifx-do.html" ><B CLASS="function" >ifx_do()</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.ifx-pconnect.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.ifx-query.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >ifx_pconnect</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.ifx.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >ifx_query</TD ></TR ></TABLE ></DIV ></BODY ></HTML >