V
V
Vadim Stepanenko2018-03-24 16:03:20
Node.js
Vadim Stepanenko, 2018-03-24 16:03:20

Is it possible to link php and node js via db?

Hello everyone
. There is a website in PHP, and a small (but very important and not normally implemented) script in node.js. There was a need to link eh.
The essence is as follows: the user sends an application, it is immediately processed on the server, and a response is generated and sent. (generation on node js)
Only the following idea came to mind:
1. The user sends a request (php)
2. The request is processed and entered into the database with status='waiting' (php)
3. The node checks the database for new records every second if there is a record, then it generates a response
4. In the database for this request, set "done" through the node.
Is it possible to do this at all? Php script and node script will be on the same server

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Shvedov, 2018-03-24
@mmmaaak

you can exchange data through some message queue, for example RabbitMQ

A
Alex Smith, 2018-03-30
@RussianSpy

In some DBMS, you do not even need to constantly pull it to get information about the update. For example, in the same PostgreSQL there is a NOTIFY / LISTEN mechanism. As a matter of fact the notification of the clients connected to a DB. More details in the doc:
https://www.postgresql.org/docs/9.6/static/sql-lis...
https://www.postgresql.org/docs/9.6/static/sql-not...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question