Re: Postgres 'notify' in PHP?

From: Date: Tue, 20 Jul 1999 00:34:32 +0000
Subject: Re: Postgres 'notify' in PHP?
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-8756@lists.php.net to get a copy of this message
Rasmus Lerdorf wrote: > I don't really see how this would work. How are you going to get Postgres > to trigger Apache to call PHP to send data to the client? Sorry, I wasn't clear enough. However, let me try to summarize; as far as I understand, listen/notify works with pgsql in the following manner: 1. application registers it's interest in event with the DB engine; 2. other application creates/sends that event; DB engine dispatches event into queues of registered frontends 3. next time the frontend reads from the frontend/backend connection, the contents of the notify queue get transferred to the frontend, where events can be retrieved with the library function PQNotifies() There also exists a function - PQconsumeInput() - that in this context can be used to poll for new notifies. According to the PostgreSQL docs below, if all incoming results and notifies are processed, one can go select() and block on the connection, as new notifies will be sent by the backend. I would be happy with having the script looping and polling until a notify condition is received, or even better the select approach (though I suspect it could be a deliberate decision not having any select-like functionality in PHP); my problem is, that I can't access PQNotifies() from PHP, and therefore can't receive notifies, so I'm forced to constantly do queries to discover changes in tables. Refs: - libpq: http://www.postgresql.org/docs/programmer/libpq-chapter.htm - notification in libpq: http://www.postgresql.org/docs/programmer/libpq-chapter3471.htm Thanks in advance, Regards, Andras Kadinger bandit@freeside.elte.hu

« previous php.dev (#8756) next »