<?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 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.pg-last-notice.php',
    1 => 'pg_last_notice',
    2 => '返回 PostgreSQL 服务器最新一条公告信息',
  ),
  'up' => 
  array (
    0 => 'ref.pgsql.php',
    1 => 'PostgreSQL 函数',
  ),
  'prev' => 
  array (
    0 => 'function.pg-last-error.php',
    1 => 'pg_last_error',
  ),
  'next' => 
  array (
    0 => 'function.pg-last-oid.php',
    1 => 'pg_last_oid',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/pgsql/functions/pg-last-notice.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.pg-last-notice" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pg_last_notice</h1> 
  <p class="verinfo">(PHP 4 &gt;= 4.0.6, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">pg_last_notice</span> &mdash; <span class="dc-title">
   返回 PostgreSQL 服务器最新一条公告信息
  </span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.pg-last-notice-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>pg_last_notice</strong></span>(<span class="methodparam"><span class="type"><a href="class.pgsql-connection.php" class="type PgSql\Connection">PgSql\Connection</a></span> <code class="parameter">$connection</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-notice-last">PGSQL_NOTICE_LAST</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>pg_last_notice()</strong></span>
   返回由 <code class="parameter">connection</code>
   指定的 PostgreSQL 服务器最新的一条 notice 信息。PostgreSQL
   服务器在某些情况下会发送 notice 信息，例如在表里创建 <code class="literal">SERIAL</code> 列。
  </p>
  <p class="para">
   使用 <span class="function"><strong>pg_last_notice()</strong></span>，只要检查 notice 是否和该事务有关，就可以避免提交无用的查询。
  </p>
  <p class="para">
   可以通过在 <var class="filename">php.ini</var> 中把 <code class="literal">pgsql.ignore_notice</code> 置为 1 来使 notice 信息追踪成为可选项。
  </p>
  <p class="para">
   可以通过在 <var class="filename">php.ini</var> 中把 <code class="literal">pgsql.log_notice</code> 置为 0 来使 notice 信息日志成为可选项。
   除非 <code class="literal">pgsql.ignore_notice</code> 为 0，否则 notice 信息不能被日志记录。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.pg-last-notice-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">connection</code></dt>
     <dd>
      <p class="para"><span class="classname"><a href="class.pgsql-connection.php" class="classname">PgSql\Connection</a></span> 实例。</p>
     </dd>
    
    
     <dt><code class="parameter">mode</code></dt>
     <dd>
      <p class="para">
       <strong><code><a href="pgsql.constants.php#constant.pgsql-notice-last">PGSQL_NOTICE_LAST</a></code></strong>（返回最后的 notice）、<strong><code><a href="pgsql.constants.php#constant.pgsql-notice-all">PGSQL_NOTICE_ALL</a></code></strong>（返回所有
       notice）或 <strong><code><a href="pgsql.constants.php#constant.pgsql-notice-clear">PGSQL_NOTICE_CLEAR</a></code></strong>（清除 notice）之一。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pg-last-notice-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   在指定 <code class="parameter">connection</code> 使用 <strong><code><a href="pgsql.constants.php#constant.pgsql-notice-last">PGSQL_NOTICE_LAST</a></code></strong>，返回包含最后一条
   notice 的 <span class="type"><a href="language.types.string.php" class="type string">string</a></span>，使用 <strong><code><a href="pgsql.constants.php#constant.pgsql-notice-all">PGSQL_NOTICE_ALL</a></code></strong> 时为 <span class="type"><a href="language.types.array.php" class="type array">array</a></span>，使用
   <strong><code><a href="pgsql.constants.php#constant.pgsql-notice-clear">PGSQL_NOTICE_CLEAR</a></code></strong> 时为 <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>。
  </p>
 </div>

 
 <div class="refsect1 changelog" id="refsect1-function.pg-last-notice-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
 <td>8.1.0</td>
 <td>
  现在 <code class="parameter">connection</code> 参数接受 <span class="classname"><a href="class.pgsql-connection.php" class="classname">PgSql\Connection</a></span>
  实例，之前接受 <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>。
 </td>
</tr>

      <tr>
       <td>7.1.0</td>
       <td>
        新增 <code class="parameter">mode</code> 参数。
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.pg-last-notice-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 <span class="function"><strong>pg_last_notice()</strong></span> 示例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />  $pgsql_conn </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbname=mark host=localhost"</span><span style="color: #007700">);<br />  <br />  </span><span style="color: #0000BB">$res </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_query</span><span style="color: #007700">(</span><span style="color: #DD0000">"CREATE TABLE test (id SERIAL)"</span><span style="color: #007700">);<br />  <br />  </span><span style="color: #0000BB">$notice </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_last_notice</span><span style="color: #007700">(</span><span style="color: #0000BB">$pgsql_conn</span><span style="color: #007700">);<br />  <br />  echo </span><span style="color: #0000BB">$notice</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>以上示例会输出：</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">CREATE TABLE will create implicit sequence &quot;test_id_seq&quot; for &quot;serial&quot; column &quot;test.id&quot;</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.pg-last-notice-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.pg-query.php" class="function" rel="rdfs-seeAlso">pg_query()</a> - 执行查询</span></li>
    <li><span class="function"><a href="function.pg-last-error.php" class="function" rel="rdfs-seeAlso">pg_last_error()</a> - 得到某连接的最后一条错误信息</span></li>
   </ul>
  </p>
 </div>


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