Last active
April 16, 2016 15:12
-
-
Save chanmix51/7115363 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This file listen to notifications from the Postgresql server. | |
// To send a notification with a payload you can either issue a NOTIFY SQL command from a psql console | |
// or use the file below. | |
// pomm https://github.com/chanmix51/Pomm | |
$database = new \Pomm\Connection\Database([ "dsn" => "pgsql://user:pass@host:port/name" ]); | |
$observer = $database->getConnection() | |
->createObserver() | |
->listen('plop'); | |
while (true) | |
{ | |
while(!$data = $observer->getNotification()) | |
{ | |
printf("."); | |
sleep(1); | |
} | |
printf("x\n"); | |
var_dump($data); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$database = new \Pomm\Connection\Database([ "dsn" => "pgsql://user:pass@host:port/name" ]); | |
$database->getConnection()->notify('plop', 'some data'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment