Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 5348

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!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>Sends a request to create a prepared statement with the given parameters, without waiting for completion.</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.pg-send-execute.html">pg_send_execute</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.pg-send-query-params.html">pg_send_query_params</a></div>
 <div class="up"><a href="ref.pgsql.html">PostgreSQL Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.pg-send-prepare" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pg_send_prepare</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0)</p><p class="refpurpose"><span class="refname">pg_send_prepare</span> &mdash; <span class="dc-title">Sends a request to create a prepared statement with the given parameters, without waiting for completion.</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.pg-send-prepare-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>pg_send_prepare</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$connection</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$stmtname</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$query</code></span>
   )</div>

  <p class="para rdfs-comment">
    Sends a request to create a prepared statement with the given parameters, 
    without waiting for completion.
  </p>
  <p class="para">
    This is an asynchronous version of  <span class="function"><a href="function.pg-prepare.html" class="function">pg_prepare()</a></span>: it returns <strong><code>TRUE</code></strong> if it was able to 
    dispatch the request, and <strong><code>FALSE</code></strong> if not. After a successful call, call 
     <span class="function"><a href="function.pg-get-result.html" class="function">pg_get_result()</a></span> to determine whether the server successfully created the 
    prepared statement. The function&#039;s parameters are handled identically to 
     <span class="function"><a href="function.pg-prepare.html" class="function">pg_prepare()</a></span>. Like  <span class="function"><a href="function.pg-prepare.html" class="function">pg_prepare()</a></span>, it will not work 
    on pre-7.4 versions of PostgreSQL.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.pg-send-prepare-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">connection</code></em></span>
     <dd>

      <p class="para">
       PostgreSQL database connection resource.  When 
       <em><code class="parameter">connection</code></em> is not present, the default connection 
       is used. The default connection is the last connection made by 
        <span class="function"><a href="function.pg-connect.html" class="function">pg_connect()</a></span> or  <span class="function"><a href="function.pg-pconnect.html" class="function">pg_pconnect()</a></span>.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">stmtname</code></em></span>
     <dd>

      <p class="para">
       The name to give the prepared statement.  Must be unique per-connection.  If
       &quot;&quot; is specified, then an unnamed statement is created, overwriting any
       previously defined unnamed statement.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">query</code></em></span>
     <dd>

      <p class="para">
       The parameterized SQL statement.  Must contain only a single statement.
       (multiple statements separated by semi-colons are not allowed.)  If any parameters 
       are used, they are referred to as $1, $2, etc.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.pg-send-prepare-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">Returns <strong><code>TRUE</code></strong> on success, <strong><code>FALSE</code></strong> on failure.  Use  <span class="function"><a href="function.pg-get-result.html" class="function">pg_get_result()</a></span>
  to determine the query result.</p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.pg-send-prepare-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2118">
    <p><strong>Example #1 Using  <span class="function"><strong>pg_send_prepare()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;$dbconn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbname=publisher"</span><span style="color: #007700">)&nbsp;or&nbsp;die(</span><span style="color: #DD0000">"Could&nbsp;not&nbsp;connect"</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Prepare&nbsp;a&nbsp;query&nbsp;for&nbsp;execution<br />&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(!</span><span style="color: #0000BB">pg_connection_busy</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">pg_send_prepare</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"my_query"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'SELECT&nbsp;*&nbsp;FROM&nbsp;shops&nbsp;WHERE&nbsp;name&nbsp;=&nbsp;$1'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$res1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_get_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">);<br />&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Execute&nbsp;the&nbsp;prepared&nbsp;query.&nbsp;&nbsp;Note&nbsp;that&nbsp;it&nbsp;is&nbsp;not&nbsp;necessary&nbsp;to&nbsp;escape<br />&nbsp;&nbsp;//&nbsp;the&nbsp;string&nbsp;"Joe's&nbsp;Widgets"&nbsp;in&nbsp;any&nbsp;way<br />&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(!</span><span style="color: #0000BB">pg_connection_busy</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">pg_send_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"my_query"</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">"Joe's&nbsp;Widgets"</span><span style="color: #007700">));<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$res2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_get_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">);<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Execute&nbsp;the&nbsp;same&nbsp;prepared&nbsp;query,&nbsp;this&nbsp;time&nbsp;with&nbsp;a&nbsp;different&nbsp;parameter<br />&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(!</span><span style="color: #0000BB">pg_connection_busy</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">pg_send_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"my_query"</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">"Clothes&nbsp;Clothes&nbsp;Clothes"</span><span style="color: #007700">));<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$res3&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_get_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">);<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.pg-send-prepare-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.pg-connect.html" class="function" rel="rdfs-seeAlso">pg_connect()</a> - Open a PostgreSQL connection</span></li>
    <li class="member"> <span class="function"><a href="function.pg-pconnect.html" class="function" rel="rdfs-seeAlso">pg_pconnect()</a> - Open a persistent PostgreSQL connection</span></li>
    <li class="member"> <span class="function"><a href="function.pg-execute.html" class="function" rel="rdfs-seeAlso">pg_execute()</a> - Sends a request to execute a prepared statement with given parameters, and waits for the result.</span></li>
    <li class="member"> <span class="function"><a href="function.pg-send-execute.html" class="function" rel="rdfs-seeAlso">pg_send_execute()</a> - Sends a request to execute a prepared statement with given parameters, without waiting for the result(s).</span></li>
    <li class="member"> <span class="function"><a href="function.pg-send-query-params.html" class="function" rel="rdfs-seeAlso">pg_send_query_params()</a> - Submits a command and separate parameters to the server without waiting for the result(s).</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.pg-send-execute.html">pg_send_execute</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.pg-send-query-params.html">pg_send_query_params</a></div>
 <div class="up"><a href="ref.pgsql.html">PostgreSQL Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>