<HTML ><HEAD ><TITLE >ifx_affected_rows</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.44"><LINK REL="HOME" TITLE="PHP Manual" HREF="manual.html"><LINK REL="UP" TITLE="Informix functions" HREF="ref.ifx.html"><LINK REL="PREVIOUS" TITLE="ifx_errormsg" HREF="function.ifx-errormsg.html"><LINK REL="NEXT" TITLE="ifx_getsqlca" HREF="function.ifx-getsqlca.html"></HEAD ><BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><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-errormsg.html" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.ifx-getsqlca.html" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.ifx-affected-rows" >ifx_affected_rows</A ></H1 ><DIV CLASS="refnamediv" ><A NAME="AEN14096" ></A >ifx_affected_rows -- Get number of rows affected by a query</DIV ><DIV CLASS="refsect1" ><A NAME="AEN14099" ></A ><H2 >Description</H2 ><DIV CLASS="funcsynopsis" ><P ></P ><CODE CLASS="FUNCDEF" >int ifx_affected_rows</CODE >(int result_id);<P ></P ></DIV ><P > <TT CLASS="parameter" ><I >result_id</I ></TT > is a valid result id returned by <A HREF="function.ifx-query.html" ><B CLASS="function" >ifx_query()</B ></A > or <A HREF="function.ifx-prepare.html" ><B CLASS="function" >ifx_prepare()</B ></A >. </P ><P > Returns the number of rows affected by a query associated with <TT CLASS="parameter" ><I >result_id</I ></TT >. </P ><P > For inserts, updates and deletes the number is the real number (sqlerrd[2]) of affected rows. For selects it is an estimate (sqlerrd[0]). Don't rely on it. The database server can never return the actual number of rows that will be returned by a SELECT because it has not even begun fetching them at this stage (just after the "PREPARE" when the optimizer has determined the query plan). </P ><P > Useful after <A HREF="function.ifx-prepare.html" ><B CLASS="function" >ifx_prepare()</B ></A > to limit queries to reasonable result sets. </P ><P > See also: <A HREF="function.ifx-num-rows.html" ><B CLASS="function" >ifx_num_rows()</B ></A > </P ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><P ><B >Example 1. Informix affected rows</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="programlisting" > 1 2 $rid = ifx_prepare ("select * from emp 3 where name like " . $name, $connid); 4 if (! $rid) { 5 ... error ... 6 } 7 $rowcount = ifx_affected_rows ($rid); 8 if ($rowcount > 1000) { 9 printf ("Too many rows in result set (%d)\n<br>", $rowcount); 10 die ("Please restrict your query<br>\n"); 11 } 12 </PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.ifx-errormsg.html" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="manual.html" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.ifx-getsqlca.html" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >ifx_errormsg</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.ifx.html" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >ifx_getsqlca</TD ></TR ></TABLE ></DIV ></BODY ></HTML >