📄 function.pg-send-query-params.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Submits a command and separate parameters to the server without waiting for the result(s).</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-send-prepare.html">pg_send_prepare</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pg-send-query.html">pg_send_query</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-query-params" class="refentry"> <div class="refnamediv"> <h1 class="refname">pg_send_query_params</h1> <p class="verinfo">(PHP 5 >= 5.1.0)</p><p class="refpurpose"><span class="refname">pg_send_query_params</span> — <span class="dc-title">Submits a command and separate parameters to the server without waiting for the result(s).</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><b><b>pg_send_query_params</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">$query</tt></span> , <span class="methodparam"><span class="type">array</span> <tt class="parameter">$params</tt></span> )</div> <p class="para rdfs-comment"> Submits a command and separate parameters to the server without waiting for the result(s). </p> <p class="para"> This is equivalent to <a href="function.pg-send-query.html" class="function">pg_send_query()</a> except that query parameters can be specified separately from the <i><tt class="parameter">query</tt></i> string. The function's parameters are handled identically to <a href="function.pg-query-params.html" class="function">pg_query_params()</a>. Like <a href="function.pg-query-params.html" class="function">pg_query_params()</a>, it will not work on pre-7.4 PostgreSQL connections, and it allows only one command in the 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. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">query</tt></i></span> <dd> <p class="para"> The parameterised 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> <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> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para">Returns <b><tt>TRUE</tt></b> on success or <b><tt>FALSE</tt></b> on failure.</p> <p class="para"> Use <a href="function.pg-get-result.html" class="function">pg_get_result()</a> to determine the query result. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 Using <b>pg_send_query_params()</b></b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /> $dbconn </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbname=publisher"</span><span style="color: #007700">) or die(</span><span style="color: #DD0000">"Could not connect"</span><span style="color: #007700">);<br /><br /> </span><span style="color: #FF8000">// Using parameters. Note that it is not necessary to quote or escape<br /> // the parameter.<br /> </span><span style="color: #0000BB">pg_send_query_params</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">, </span><span style="color: #DD0000">'select count(*) from authors where city = $1'</span><span style="color: #007700">, array(</span><span style="color: #DD0000">'Perth'</span><span style="color: #007700">));<br /> <br /> </span><span style="color: #FF8000">// Compare against basic pg_send_query usage<br /> </span><span style="color: #0000BB">$str </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_escape_string</span><span style="color: #007700">(</span><span style="color: #DD0000">'Perth'</span><span style="color: #007700">);<br /> </span><span style="color: #0000BB">pg_send_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">, </span><span style="color: #DD0000">"select count(*) from authors where city = '${str}'"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></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-send-query.html" class="function" rel="rdfs-seeAlso">pg_send_query()</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-send-prepare.html">pg_send_prepare</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pg-send-query.html">pg_send_query</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 + -