Jump to content

Problem With Postgresql Notify Payload In Php


matpiot

Recommended Posts

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.

Link to comment
Share on other sites

  • 4 weeks later...

Your connection string should be,

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...