<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Execute a previously prepared query</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ibase-errmsg.html">ibase_errmsg</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ibase-fetch-assoc.html">ibase_fetch_assoc</a></div> <div class="up"><a href="ref.ibase.html">Firebird/InterBase Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.ibase-execute" class="refentry"> <div class="refnamediv"> <h1 class="refname">ibase_execute</h1> <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">ibase_execute</span> — <span class="dc-title">Execute a previously prepared query</span></p> </div> <div class="refsect1 description" id="refsect1-function.ibase-execute-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">resource</span> <span class="methodname"><strong>ibase_execute</strong></span> ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$query</code></span> [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$bind_arg</code></span> [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$...</code></span> ]] )</div> <p class="para rdfs-comment"> Execute a query prepared by <span class="function"><a href="function.ibase-prepare.html" class="function">ibase_prepare()</a></span>. </p> <p class="para"> This is a lot more effective than using <span class="function"><a href="function.ibase-query.html" class="function">ibase_query()</a></span> if you are repeating a same kind of query several times with only some parameters changing. </p> </div> <div class="refsect1 parameters" id="refsect1-function.ibase-execute-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">query</code></em></span> <dd> <p class="para"> An InterBase query prepared by <span class="function"><a href="function.ibase-prepare.html" class="function">ibase_prepare()</a></span>. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">bind_arg</code></em></span> <dd> <p class="para"> </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">...</code></em></span> <dd> <p class="para"> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.ibase-execute-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> If the query raises an error, returns <strong><code>FALSE</code></strong>. If it is successful and there is a (possibly empty) result set (such as with a SELECT query), returns a result identifier. If the query was successful and there were no results, returns <strong><code>TRUE</code></strong>. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> This function returns the number of rows affected by the query (if > 0 and applicable to the statement type). A query that succeeded, but did not affect any rows (e.g. an UPDATE of a non-existent record) will return <strong><code>TRUE</code></strong>. </p> </p></blockquote> </div> <div class="refsect1 examples" id="refsect1-function.ibase-execute-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-1107"> <p><strong>Example #1 <span class="function"><strong>ibase_execute()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br />$dbh </span><span style="color: #007700">= </span><span style="color: #0000BB">ibase_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$host</span><span style="color: #007700">, </span><span style="color: #0000BB">$username</span><span style="color: #007700">, </span><span style="color: #0000BB">$password</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$updates </span><span style="color: #007700">= array(<br /> </span><span style="color: #0000BB">1 </span><span style="color: #007700">=> </span><span style="color: #DD0000">'Eric'</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">5 </span><span style="color: #007700">=> </span><span style="color: #DD0000">'Filip'</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">7 </span><span style="color: #007700">=> </span><span style="color: #DD0000">'Larry'<br /></span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$query </span><span style="color: #007700">= </span><span style="color: #0000BB">ibase_prepare</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbh</span><span style="color: #007700">, </span><span style="color: #DD0000">"UPDATE FOO SET BAR = ? WHERE BAZ = ?"</span><span style="color: #007700">);<br /><br />foreach (</span><span style="color: #0000BB">$updates </span><span style="color: #007700">as </span><span style="color: #0000BB">$baz </span><span style="color: #007700">=> </span><span style="color: #0000BB">$bar</span><span style="color: #007700">) {<br /> </span><span style="color: #0000BB">ibase_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">, </span><span style="color: #0000BB">$bar</span><span style="color: #007700">, </span><span style="color: #0000BB">$baz</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-function.ibase-execute-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.ibase-query.html" class="function" rel="rdfs-seeAlso">ibase_query()</a> - Execute a query on an InterBase database</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ibase-errmsg.html">ibase_errmsg</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ibase-fetch-assoc.html">ibase_fetch_assoc</a></div> <div class="up"><a href="ref.ibase.html">Firebird/InterBase Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>