⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 function.pg-execute.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Sends a request to execute a prepared statement with given parameters, and waits for the result.</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.pg-escape-string.html">pg_escape_string</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pg-fetch-all-columns.html">pg_fetch_all_columns</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-execute" class="refentry"> <div class="refnamediv">  <h1 class="refname">pg_execute</h1>  <p class="verinfo">(PHP 5 &gt;= 5.1.0)</p><p class="refpurpose"><span class="refname">pg_execute</span> &mdash; <span class="dc-title">Sends a request to execute a prepared statement with given parameters, and waits for the result.</span></p> </div> <div class="refsect1 description">  <h3 class="title">Description</h3>  <div class="methodsynopsis dc-description">   <span class="type">resource</span> <span class="methodname"><b><b>pg_execute</b></b></span>    ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$connection</tt></span>   , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$stmtname</tt></span>   , <span class="methodparam"><span class="type">array</span> <tt class="parameter">$params</tt></span>   )</div>  <div class="methodsynopsis dc-description">   <span class="type">resource</span> <span class="methodname"><b><b>pg_execute</b></b></span>    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$stmtname</tt></span>   , <span class="methodparam"><span class="type">array</span> <tt class="parameter">$params</tt></span>   )</div>  <p class="para rdfs-comment">    Sends a request to execute a prepared statement with given parameters, and     waits for the result.  </p>  <p class="para">    <b>pg_execute()</b> is like <a href="function.pg-query-params.html" class="function">pg_query_params()</a>,     but the command to be executed is     specified by naming a previously-prepared statement, instead of giving a     query string. This feature allows commands that will be used repeatedly to     be parsed and planned just once, rather than each time they are executed.     The statement must have been prepared previously in the current session.     <b>pg_execute()</b> is supported only against PostgreSQL 7.4 or    higher connections; it will fail when using earlier versions.  </p>  <p class="para">    The parameters are identical to <a href="function.pg-query-params.html" class="function">pg_query_params()</a>, except that the name of a     prepared statement is given instead of a query string.  </p> </div><div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">connection</tt></i></span>     <dd>      <p class="para">       PostgreSQL database connection resource.  When        <i><tt class="parameter">connection</tt></i> is not present, the default connection        is used. The default connection is the last connection made by        <a href="function.pg-connect.html" class="function">pg_connect()</a> or <a href="function.pg-pconnect.html" class="function">pg_pconnect()</a>.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">stmtname</tt></i></span>     <dd>      <p class="para">       The name of the prepared statement to execute.  if       &quot;&quot; is specified, then the unnamed statement is executed.  The name must have       been previously prepared using <a href="function.pg-prepare.html" class="function">pg_prepare()</a>,        <a href="function.pg-send-prepare.html" class="function">pg_send_prepare()</a> or a <i>PREPARE</i> SQL       command.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">params</tt></i></span>     <dd>      <p class="para">        An array of parameter values to substitute for the $1, $2, etc. placeholders        in the original prepared query string.  The number of elements in the array        must match the number of placeholders.      </p>      <div class="warning"><b class="warning">Warning</b>       <p class="para">        Elements are converted to strings by calling this function.       </p>      </div>     </dd>    </dt>   </dl>  </p> </div> <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">    A query result resource on success, or <b><tt>FALSE</tt></b> on failure.</p> </div>  <div class="refsect1 examples">  <h3 class="title">Examples</h3>  <p class="para">   <div class="example">    <p><b>Example #1 Using <b>pg_execute()</b></b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Connect&nbsp;to&nbsp;a&nbsp;database&nbsp;named&nbsp;"mary"<br /></span><span style="color: #0000BB">$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=mary"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Prepare&nbsp;a&nbsp;query&nbsp;for&nbsp;execution<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_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 /><br /></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;the&nbsp;string&nbsp;"Joe's&nbsp;Widgets"&nbsp;in&nbsp;any&nbsp;way<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_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 /><br /></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 /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_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 /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>   </div>  </p> </div>  <div class="refsect1 seealso">  <h3 class="title">See Also</h3>  <p class="para">   <ul class="simplelist">    <li class="member"><a href="function.pg-prepare.html" class="function" rel="rdfs-seeAlso">pg_prepare()</a></li>    <li class="member"><a href="function.pg-send-prepare.html" class="function" rel="rdfs-seeAlso">pg_send_prepare()</a></li>    <li class="member"><a href="function.pg-query-params.html" class="function" rel="rdfs-seeAlso">pg_query_params()</a></li>   </ul>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.pg-escape-string.html">pg_escape_string</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pg-fetch-all-columns.html">pg_fetch_all_columns</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>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -