<?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 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.pg-get-notify.php',
    1 => 'pg_get_notify',
    2 => 'Ottiene il messaggio SQL NOTIFY',
  ),
  'up' => 
  array (
    0 => 'ref.pgsql.php',
    1 => 'PostgreSQL Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.pg-free-result.php',
    1 => 'pg_free_result',
  ),
  'next' => 
  array (
    0 => 'function.pg-get-pid.php',
    1 => 'pg_get_pid',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'it',
    'path' => 'reference/pgsql/functions/pg-get-notify.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.pg-get-notify" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pg_get_notify</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">pg_get_notify</span> &mdash; <span class="dc-title">Ottiene il messaggio SQL NOTIFY</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.pg-get-notify-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>pg_get_notify</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-assoc">PGSQL_ASSOC</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.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>pg_get_notify()</strong></span> riceve notifiche generate da un
   comando SQL <code class="literal">NOTIFY</code>. Per ricevere le notifiche,
   è necessario eseguire il comando SQL
   <code class="literal">LISTEN</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.pg-get-notify-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">connection</code></dt>
     <dd>
      <p class="para">An <span class="classname"><a href="class.pgsql-connection.php" class="classname">PgSql\Connection</a></span> instance.</p>
     </dd>
    
    
     <dt><code class="parameter">mode</code></dt>
     <dd>
      <p class="para">
An optional parameter that controls how the returned <span class="type"><a href="language.types.array.php" class="type array">array</a></span> is indexed.
<code class="parameter">mode</code> is a constant and can take the following values:
<strong><code><a href="pgsql.constants.php#constant.pgsql-assoc">PGSQL_ASSOC</a></code></strong>, <strong><code><a href="pgsql.constants.php#constant.pgsql-num">PGSQL_NUM</a></code></strong> and <strong><code><a href="pgsql.constants.php#constant.pgsql-both">PGSQL_BOTH</a></code></strong>.
Using <strong><code><a href="pgsql.constants.php#constant.pgsql-num">PGSQL_NUM</a></code></strong>, the function will return an array with numerical indices,
using <strong><code><a href="pgsql.constants.php#constant.pgsql-assoc">PGSQL_ASSOC</a></code></strong> it will return only associative indices
while <strong><code><a href="pgsql.constants.php#constant.pgsql-both">PGSQL_BOTH</a></code></strong> will return both numerical and associative indices.</p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pg-get-notify-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   Un <span class="type"><a href="language.types.array.php" class="type array">array</a></span> contenente il nome del messaggio <code class="literal">NOTIFY</code> e il PID di backend.
   Se supportato dal server, l&#039;array contiene anche la versione del server e il payload.
   Altrimenti se non è in attesa alcuna <code class="literal">NOTIFY</code>, allora viene restituito <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.pg-get-notify-changelog">
  <h3 class="title">Log delle modifiche</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Versione</th>
      <th>Descrizione</th>
     </tr>

    </thead>

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

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.pg-get-notify-examples">
  <h3 class="title">Esempi</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 Messaggio NOTIFY di PostgreSQL</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php <br />$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 />if (!</span><span style="color: #0000BB">$conn</span><span style="color: #007700">) {<br />  echo </span><span style="color: #DD0000">"Si è verificato un errore.\n"</span><span style="color: #007700">;<br />  exit;<br />}<br /><br /></span><span style="color: #FF8000">// Ascolta il messaggio 'author_updated' da altri processi<br /></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">'LISTEN author_updated;'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$notify </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_get_notify</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">$notify</span><span style="color: #007700">) {<br />  echo </span><span style="color: #DD0000">"Nessun messaggio\n"</span><span style="color: #007700">;<br />} else {<br />  </span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$notify</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 seealso" id="refsect1-function.pg-get-notify-seealso">
  <h3 class="title">Vedere anche:</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.pg-get-pid.php" class="function" rel="rdfs-seeAlso">pg_get_pid()</a> - Ottiene l'ID del processo del backend</span></li>
   </ul>
  </p>
 </div>

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