Method Sql.pgsql()->set_notify_callback()
- Method
set_notify_callback
final
void
set_notify_callback(string
condition
,void
|function
(int
,string
,string
,mixed
... :void
)notify_cb
,void
|int
selfnotify
,mixed
...args
)- Description
With PostgreSQL you can LISTEN to NOTIFY events. This function allows you to detect and handle such events.
- Parameter
condition
Name of the notification event we're listening to. A special case is the empty string, which matches all events, and can be used as fallback function which is called only when the specific condition is not handled. Another special case is
"_lost"
which gets called whenever the connection to the database unexpectedly drops.- Parameter
notify_cb
Function to be called on receiving a notification-event of condition
condition
. The callback function is invoked withvoid notify_cb(pid,condition,extrainfo, .. args);
pid is the process id of the database session that originated the event. condition contains the current condition. extrainfo contains optional extra information specified by the database. The rest of the arguments tonotify_cb
are passed verbatim fromargs
. The callback function must return no value.- Parameter
selfnotify
Normally notify events generated by your own session are ignored. If you want to receive those as well, set
selfnotify
to one.- Parameter
args
Extra arguments to pass to
notify_cb
.- Note
This function is PostgreSQL-specific.