Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 5345

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>Get status of query result</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.pg-result-seek.html">pg_result_seek</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.pg-select.html">pg_select</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-result-status" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pg_result_status</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5)</p><p class="refpurpose"><span class="refname">pg_result_status</span> &mdash; <span class="dc-title">
   Get status of query result
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.pg-result-status-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_result_status</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$result</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$type</code><span class="initializer"> = PGSQL_STATUS_LONG</span></span>
  ] )</div>

  <p class="para rdfs-comment">
    <span class="function"><strong>pg_result_status()</strong></span> returns the status of a result
   resource, or the PostgreSQL command completion tag associated with the result
  </p>
 </div>


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

    <dt>

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

      <p class="para">
       PostgreSQL query result resource, returned by  <span class="function"><a href="function.pg-query.html" class="function">pg_query()</a></span>,
        <span class="function"><a href="function.pg-query-params.html" class="function">pg_query_params()</a></span> or  <span class="function"><a href="function.pg-execute.html" class="function">pg_execute()</a></span>
       (among others).
      </p>
     </dd>

    </dt>

    <dt>

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

      <p class="para">
       Either <strong><code>PGSQL_STATUS_LONG</code></strong> to return the numeric status 
       of the <em><code class="parameter">result</code></em>, or <strong><code>PGSQL_STATUS_STRING</code></strong> 
       to return the command tag of the <em><code class="parameter">result</code></em>.
       If not specified, <strong><code>PGSQL_STATUS_LONG</code></strong> is the default.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pg-result-status-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Possible return values are <strong><code>PGSQL_EMPTY_QUERY</code></strong>,
   <strong><code>PGSQL_COMMAND_OK</code></strong>, <strong><code>PGSQL_TUPLES_OK</code></strong>, <strong><code>PGSQL_COPY_OUT</code></strong>,
   <strong><code>PGSQL_COPY_IN</code></strong>, <strong><code>PGSQL_BAD_RESPONSE</code></strong>, <strong><code>PGSQL_NONFATAL_ERROR</code></strong> and
   <strong><code>PGSQL_FATAL_ERROR</code></strong> if <strong><code>PGSQL_STATUS_LONG</code></strong> is
   specified.  Otherwise, a <span class="type"><a href="language.types.string.html" class="type string">string</a></span> containing the PostgreSQL command tag is returned.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.pg-result-status-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>4.3.0</td>
       <td>
        The <em><code class="parameter">type</code></em> parameter was added.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.pg-result-status-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2115">
    <p><strong>Example #1  <span class="function"><strong>pg_result_status()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;Connect&nbsp;to&nbsp;the&nbsp;database<br /></span><span style="color: #0000BB">$conn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_pconnect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbname=publisher"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Execute&nbsp;a&nbsp;COPY<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"COPY&nbsp;authors&nbsp;FROM&nbsp;STDIN;"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Get&nbsp;the&nbsp;result&nbsp;status<br /></span><span style="color: #0000BB">$status&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_result_status</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Determine&nbsp;status<br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">$status&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #0000BB">PGSQL_COPY_IN</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Copy&nbsp;began."</span><span style="color: #007700">;<br />else<br />&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Copy&nbsp;failed."</span><span style="color: #007700">;<br />&nbsp;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Copy began.
</pre></div>
    </div>
   </div>
  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.pg-result-status-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.pg-connection-status.html" class="function" rel="rdfs-seeAlso">pg_connection_status()</a> - Get connection status</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-seek.html">pg_result_seek</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.pg-select.html">pg_select</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>