<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
  <refentry id="function.mysqli-execute">
   <refnamediv>
    <refname>mysqli_execute</refname>
    <refpurpose>Executes a prepared Query</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>mysqli_execute</methodname>
      <methodparam><type>resource</type><parameter>stmt</parameter></methodparam>
     </methodsynopsis>
    <para>
    The <function>mysqli_execute</function> function executes a query that has been previously
    prepared using the <function>mysqli_prepare</function> function represented by the
    <parameter>stmt</parameter> resource. When executed any parameter markers which exist will
    automatically be replaced with the appropiate data.
    </para>
    <para>
    If the statement is UPDATE, DELETE, or INSERT, the total number of affected rows can be
    determined by using the <function>mysqli_stmt_affected_rows</function> function. Likewise,
    if the query yields a result set the <function>mysqli_fetch</function> function is used.
    </para>
    <note>
     <para>
     When using <function>mysqli_execute</function>, the <function>mysqli_fetch</function>
     function must be used to fetch the data prior to preforming any additional queries.
     </para>
    </note>
    <para>
      <example>
      <title>Using the mysqli_execute function</title>
      <programlisting role="php">
<![CDATA[
<?php
    
    /* Open a connection */
    $link = mysqli_connect("localhost", "user", "pass");
    mysqli_select_db("mydb");
    
    /* Turn on autocommit */
    mysqli_autocommit($link, true);
    
    /* Prepare an insert statement */
    $query = "INSERT INTO mytable VALUES(?, ?)";
    $stmt = mysqli_prepare($link, $query);
    
    $value_one = "hello";
    $value_two = "world";
    
    mysqli_bind_param($link, $value_one, $value_two);
    
    /* Execute the statement */
    mysqli_execute($stmt);
    
    /* Return the affected rows for the statement */
    $affected_rows = mysqli_stmt_affected_rows($stmt);
    
    /* Close the statement */
    
    mysqli_stmt_close($stmt);
    
    echo "The total affected rows was $affected_rows";
    
?>
]]>
      </programlisting>
     </example>
    </para>
   </refsect1>
  </refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->