📄 function.pg-get-notify.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Gets SQL NOTIFY message</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.pg-free-result.html">pg_free_result</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pg-get-pid.html">pg_get_pid</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-get-notify" class="refentry"> <div class="refnamediv"> <h1 class="refname">pg_get_notify</h1> <p class="verinfo">(PHP 4 >= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">pg_get_notify</span> — <span class="dc-title">Gets SQL NOTIFY message</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><b><b>pg_get_notify</b></b></span> ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$connection</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$result_type</tt></span> ] )</div> <p class="para rdfs-comment"> <b>pg_get_notify()</b> gets notifications generated by a <i>NOTIFY</i> SQL command. To receive notifications, the <i>LISTEN</i> SQL command must be issued. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">connection</tt></i></span> <dd> <p class="para"> PostgreSQL database connection resource. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">result_type</tt></i></span> <dd> <p class="para"> An optional parameter that controls how the returned <a href="language.types.array.html" class="type array">array</a> is indexed. <i><tt class="parameter">result_type</tt></i> is a constant and can take the following values: <b><tt>PGSQL_ASSOC</tt></b>, <b><tt>PGSQL_NUM</tt></b> and <b><tt>PGSQL_BOTH</tt></b>. Using <b><tt>PGSQL_NUM</tt></b>, <b>pg_get_notify()</b> will return an array with numerical indices, using <b><tt>PGSQL_ASSOC</tt></b> it will return only associative indices while <b><tt>PGSQL_BOTH</tt></b>, the default, will return both numerical and associative indices. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> An <a href="language.types.array.html" class="type array">array</a> containing the <i>NOTIFY</i> message name and backend PID. Otherwise if no <i>NOTIFY</i> is waiting, then <b><tt>FALSE</tt></b> is returned. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 PostgreSQL NOTIFY message</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?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">"An error occured.\n"</span><span style="color: #007700">;<br /> exit;<br />}<br /><br /></span><span style="color: #FF8000">// Listen 'author_updated' message from other processes<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">"No messages\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">?></span></span></code></div> </div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.pg-get-pid.html" class="function" rel="rdfs-seeAlso">pg_get_pid()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.pg-free-result.html">pg_free_result</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pg-get-pid.html">pg_get_pid</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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -