📄 function.pg-select.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Select records</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-result-status.html">pg_result_status</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pg-send-execute.html">pg_send_execute</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-select" class="refentry"> <div class="refnamediv"> <h1 class="refname">pg_select</h1> <p class="verinfo">(PHP 4 >= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">pg_select</span> — <span class="dc-title"> Select records </span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><b><b>pg_select</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">$table_name</tt></span> , <span class="methodparam"><span class="type">array</span> <tt class="parameter">$assoc_array</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$options</tt></span> ] )</div> <p class="para rdfs-comment"> <b>pg_select()</b> selects records specified by <i>assoc_array</i> which has <i>field=>value</i>. For a successful query, it returns an array containing all records and fields that match the condition specified by <i>assoc_array</i>. </p> <p class="para">If <i>options</i> is specified, <a href="function.pg-convert.html" class="function">pg_convert()</a> is applied to <i>assoc_array</i> with the specified flags. </p> <div class="warning"><b class="warning">Warning</b><p class="simpara">This function is<em class="emphasis">EXPERIMENTAL</em>. The behaviour of this function, its name, andsurrounding documentation may change without notice in a future release of PHP.This function should be used at your own risk.</p></div> </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">table_name</tt></i></span> <dd> <p class="para"> Name of the table from which to select rows. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">assoc_array</tt></i></span> <dd> <p class="para"> An <a href="language.types.array.html" class="type array">array</a> whose keys are field names in the table <i><tt class="parameter">table_name</tt></i>, and whose values are the conditions that a row must meet to be retrieved. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">options</tt></i></span> <dd> <p class="para"> Any number of <b><tt>PGSQL_CONV_FORCE_NULL</tt></b>, <b><tt>PGSQL_DML_NO_CONV</tt></b>, <b><tt>PGSQL_DML_EXEC</tt></b>, <b><tt>PGSQL_DML_ASYNC</tt></b> or <b><tt>PGSQL_DML_STRING</tt></b> combined. If <b><tt>PGSQL_DML_STRING</tt></b> is part of the <i><tt class="parameter">options</tt></i> then query string is returned. </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. Returns <a href="language.types.string.html" class="type string">string</a> if <b><tt>PGSQL_DML_STRING</tt></b> is passed via <i><tt class="parameter">options</tt></i>. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 <b>pg_select()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php <br /> $db </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'dbname=foo'</span><span style="color: #007700">);<br /> </span><span style="color: #FF8000">// This is safe, since $_POST is converted automatically<br /> </span><span style="color: #0000BB">$rec </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_select</span><span style="color: #007700">(</span><span style="color: #0000BB">$db</span><span style="color: #007700">, </span><span style="color: #DD0000">'post_log'</span><span style="color: #007700">, </span><span style="color: #0000BB">$_POST</span><span style="color: #007700">);<br /> if (</span><span style="color: #0000BB">$rec</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">"Records selected\n"</span><span style="color: #007700">;<br /> </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$rec</span><span style="color: #007700">);<br /> } else {<br /> echo </span><span style="color: #DD0000">"User must have sent wrong inputs\n"</span><span style="color: #007700">;<br /> }<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-convert.html" class="function" rel="rdfs-seeAlso">pg_convert()</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-result-status.html">pg_result_status</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pg-send-execute.html">pg_send_execute</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 + -