Sophie

Sophie

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

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>Select records</title>

 </head>
 <body><div class="manualnavbar" 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 &gt;= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">pg_select</span> &mdash; <span class="dc-title">
   Select records
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.pg-select-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"><strong>pg_select</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">$table_name</code></span>
   , <span class="methodparam"><span class="type">array</span> <code class="parameter">$assoc_array</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code><span class="initializer"> = PGSQL_DML_EXEC</span></span>
  ] )</div>

  <p class="para rdfs-comment">
    <span class="function"><strong>pg_select()</strong></span> selects records specified by
   <em>assoc_array</em> which has
   <em>field=&gt;value</em>. For a successful query, it returns an
   array containing all records and fields that match the condition
   specified by <em>assoc_array</em>.
  </p>
  <p class="para">If <em>options</em> is specified,
    <span class="function"><a href="function.pg-convert.html" class="function">pg_convert()</a></span> is applied to
   <em>assoc_array</em> with the specified flags.
  </p>
  <div class="warning"><strong class="warning">Warning</strong><p class="simpara">This function is
<em class="emphasis">EXPERIMENTAL</em>. The behaviour of this function, its name, and
surrounding 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" id="refsect1-function.pg-select-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.
      </p>
     </dd>

    </dt>

    <dt>

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

      <p class="para">
       Name of the table from which to select rows.
      </p>
     </dd>

    </dt>

    <dt>

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

      <p class="para">
       An <span class="type"><a href="language.types.array.html" class="type array">array</a></span> whose keys are field names in the table <em><code class="parameter">table_name</code></em>,
       and whose values are the conditions that a row must meet to be retrieved.
      </p>
     </dd>

    </dt>

    <dt>

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

      <p class="para">
       Any number of <strong><code>PGSQL_CONV_FORCE_NULL</code></strong>, 
       <strong><code>PGSQL_DML_NO_CONV</code></strong>,
       <strong><code>PGSQL_DML_EXEC</code></strong>,
       <strong><code>PGSQL_DML_ASYNC</code></strong> or
       <strong><code>PGSQL_DML_STRING</code></strong> combined. If <strong><code>PGSQL_DML_STRING</code></strong> is part of the
       <em><code class="parameter">options</code></em> then query string is returned.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pg-select-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on failure.  Returns <span class="type"><a href="language.types.string.html" class="type string">string</a></span> if <strong><code>PGSQL_DML_STRING</code></strong> is passed
   via <em><code class="parameter">options</code></em>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.pg-select-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2116">
    <p><strong>Example #1  <span class="function"><strong>pg_select()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php&nbsp;<br />&nbsp;&nbsp;$db&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=foo'</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;This&nbsp;is&nbsp;safe,&nbsp;since&nbsp;$_POST&nbsp;is&nbsp;converted&nbsp;automatically<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$rec&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_select</span><span style="color: #007700">(</span><span style="color: #0000BB">$db</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'post_log'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">);<br />&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$rec</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Records&nbsp;selected\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$rec</span><span style="color: #007700">);<br />&nbsp;&nbsp;}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"User&nbsp;must&nbsp;have&nbsp;sent&nbsp;wrong&nbsp;inputs\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

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


 <div class="refsect1 changelog" id="refsect1-function.pg-select-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.5.3/5.4.19</td>
       <td>Direct SQL injection to <em><code class="parameter">table_name</code></em> and Indirect SQL injection to identifiers are fixed.</td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.pg-select-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.pg-convert.html" class="function" rel="rdfs-seeAlso">pg_convert()</a> - Convert associative array values into suitable for SQL statement</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-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>