<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.pgsql.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.pg-result-status.php',
    1 => 'pg_result_status',
    2 => 'Get status of query result',
  ),
  'up' => 
  array (
    0 => 'ref.pgsql.php',
    1 => 'PostgreSQL Functions',
  ),
  'prev' => 
  array (
    0 => 'function.pg-result-seek.php',
    1 => 'pg_result_seek',
  ),
  'next' => 
  array (
    0 => 'function.pg-select.php',
    1 => 'pg_select',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/pgsql/functions/pg-result-status.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<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, PHP 7, PHP 8)</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="methodname"><strong>pg_result_status</strong></span>(<span class="methodparam"><span class="type"><a href="class.pgsql-result.php" class="type PgSql\Result">PgSql\Result</a></span> <code class="parameter">$result</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$mode</code><span class="initializer"> = <strong><code><a href="pgsql.constants.php#constant.pgsql-status-long">PGSQL_STATUS_LONG</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>pg_result_status()</strong></span> returns the status of the <span class="classname"><a href="class.pgsql-result.php" class="classname">PgSql\Result</a></span> instance,
   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><code class="parameter">result</code></dt>
     <dd>
      <p class="para">An <span class="classname"><a href="class.pgsql-result.php" class="classname">PgSql\Result</a></span> instance, returned by <span class="function"><a href="function.pg-query.php" class="function">pg_query()</a></span>,
<span class="function"><a href="function.pg-query-params.php" class="function">pg_query_params()</a></span> or <span class="function"><a href="function.pg-execute.php" class="function">pg_execute()</a></span>(among others).</p>
     </dd>
    
    
     <dt><code class="parameter">mode</code></dt>
     <dd>
      <p class="para">
       Either <strong><code><a href="pgsql.constants.php#constant.pgsql-status-long">PGSQL_STATUS_LONG</a></code></strong> to return the numeric status 
       of the <code class="parameter">result</code>, or <strong><code><a href="pgsql.constants.php#constant.pgsql-status-string">PGSQL_STATUS_STRING</a></code></strong> 
       to return the command tag of the <code class="parameter">result</code>.
       If not specified, <strong><code><a href="pgsql.constants.php#constant.pgsql-status-long">PGSQL_STATUS_LONG</a></code></strong> is the default.
      </p>
     </dd>
    
   </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><a href="pgsql.constants.php#constant.pgsql-empty-query">PGSQL_EMPTY_QUERY</a></code></strong>,
   <strong><code><a href="pgsql.constants.php#constant.pgsql-command-ok">PGSQL_COMMAND_OK</a></code></strong>, <strong><code><a href="pgsql.constants.php#constant.pgsql-tuples-ok">PGSQL_TUPLES_OK</a></code></strong>, <strong><code><a href="pgsql.constants.php#constant.pgsql-tuples-chunk">PGSQL_TUPLES_CHUNK</a></code></strong>, <strong><code><a href="pgsql.constants.php#constant.pgsql-copy-out">PGSQL_COPY_OUT</a></code></strong>,
   <strong><code><a href="pgsql.constants.php#constant.pgsql-copy-in">PGSQL_COPY_IN</a></code></strong>, <strong><code><a href="pgsql.constants.php#constant.pgsql-bad-response">PGSQL_BAD_RESPONSE</a></code></strong>, <strong><code><a href="pgsql.constants.php#constant.pgsql-nonfatal-error">PGSQL_NONFATAL_ERROR</a></code></strong> and
   <strong><code><a href="pgsql.constants.php#constant.pgsql-fatal-error">PGSQL_FATAL_ERROR</a></code></strong> if <strong><code><a href="pgsql.constants.php#constant.pgsql-status-long">PGSQL_STATUS_LONG</a></code></strong> is
   specified.  Otherwise, a <span class="type"><a href="language.types.string.php" 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>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.1.0</td>
 <td>
  The <code class="parameter">result</code> parameter expects an <span class="classname"><a href="class.pgsql-result.php" class="classname">PgSql\Result</a></span>
  instance now; previously, a <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> was expected.
 </td>
</tr>

    </tbody>
   
  </table>

 </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-1">
    <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">// Connect to the database<br /></span><span style="color: #0000BB">$conn </span><span style="color: #007700">= </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">// Execute a COPY<br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #DD0000">"COPY authors FROM STDIN;"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Get the result status<br /></span><span style="color: #0000BB">$status </span><span style="color: #007700">= </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">// Determine status<br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">$status </span><span style="color: #007700">== </span><span style="color: #0000BB">PGSQL_COPY_IN</span><span style="color: #007700">)<br />   echo </span><span style="color: #DD0000">"Copy began."</span><span style="color: #007700">;<br />else<br />   echo </span><span style="color: #DD0000">"Copy failed."</span><span style="color: #007700">;<br /> <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="examplescode"><pre class="examplescode">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><span class="function"><a href="function.pg-connection-status.php" class="function" rel="rdfs-seeAlso">pg_connection_status()</a> - Get connection status</span></li>
   </ul>
  </p>
 </div>

</div><?php manual_footer($setup); ?>