<HTML ><HEAD ><TITLE >ifx_affected_rows</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="Informix functions" HREF="ref.ifx.html"><LINK REL="NEXT" TITLE="ifx_blobinfile_mode" HREF="function.ifx-blobinfile-mode.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="ref.ifx.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-blobinfile-mode.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.ifx-affected-rows" ></A >ifx_affected_rows</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN39518" ></A ><P > (PHP 3>= 3.0.3, PHP 4 )</P >ifx_affected_rows -- Get number of rows affected by a query</DIV ><DIV CLASS="refsect1" ><A NAME="AEN39521" ></A ><H2 >Description</H2 >int <B CLASS="methodname" >ifx_affected_rows</B > ( int result_id)<BR ></BR ><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" ><A NAME="AEN39540" ></A ><P ><B >Example 1. Informix affected rows</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" >$rid = ifx_prepare ("select * from emp where name like " . $name, $connid); if (! $rid) { ... error ... } $rowcount = ifx_affected_rows ($rid); if ($rowcount > 1000) { printf ("Too many rows in result set (%d)\n<br>", $rowcount); die ("Please restrict your query<br>\n"); }</PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ></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="ref.ifx.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-blobinfile-mode.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Informix functions</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_blobinfile_mode</TD ></TR ></TABLE ></DIV ></BODY ></HTML >