-2

I have a PostgreSQL, php5, running on Apache2.0 (on a Windows machine.)

I want to be able to push updates to the client's browser when certain table rows are updated. I came across this https://github.com/brianc/node-postgres

  1. What & how do I set up on server side?
  2. How do I install/setup node-postgres?
  3. Does node-postgres assume I am already using node.js or is it a complete package?
  4. How do I send client browsers messages when specified tables are updated?

I just need some direction to get started! Thanks :)

Joe B
  • 1,261
  • 14
  • 20
  • It's a library/module to use inside of a Node.js application. Usage of it assumes you have Node.js installed and know how to write Node.js apps. To push data to the browser, you're also going to want to use something like socket.io. It sounds like you're starting at zero; A good place to start is here: http://www.youtube.com/watch?v=jo_B4LTHi3I – Ryan Olds Jun 14 '12 at 17:29
  • .I am starting from basically zero. So far the video looks helpful. Thanks! – Joe B Jun 14 '12 at 17:41

1 Answers1

2
  1. You need to install Node.js with Npm on your server. You can find more information on the official Node.js.
  2. npm install pg
  3. No, see step 1
  4. Node.js should listen to your database for changes. I am not a postgres expert so I don't know if this is possible. If it is possible you should have your client-side Javascript connect to your Node.js server. You have some options here like polling with ajax. If you want something more advanced you could use socket.io.

You could also use message queues to talk between Node.js and Php. This means that you need to create a message in php though which is more complex than just having Node.js polling your database (if possible). Not sure if there are message queues that talk HTTP but if there are you don't even need to use Node.js at all. You can have your client-side talk to your message queue.

Pickels
  • 33,902
  • 26
  • 118
  • 178