Jump to content

Problem With Postgresql Notify Payload In Php


Recommended Posts

Posted

I can't retrive payload field of pgnotify object. Here's an example script which describes my problem:

 

<?php
$conn = pg_connect("host=stevie.heliohost.org port=5432 dbname= user= password=");

pg_query($conn, "LISTEN channel;");
pg_query($conn, "NOTIFY channel, 'message';");
do{
$notify = pg_get_notify($conn);
Sleep(1);
}while(!$notify);
if (!$notify) {
echo "No messages ";
} else {
echo json_encode($notify);
}
?>

 

Result when ran on stevie server:

{"message":"channel","pid":11109}

 

Expected result (recived after running this code on localhost xampp server):

{"message":"channel","pid":9225,"payload":"message"}

 

I belive that the problem might be the version of the pgsql extension. Is there any chance for upgrade or maybe I'm missing something and there is other solution to this problem? Any help would be appreciated.

  • 4 weeks later...
Posted

Your connection string should be,

$conn = pg_connect("host=localhost port=5432 user=db_user password=db_pwd dbname=db_name");

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...