Comments - Non-blocking calls from PHP

8 years, 9 months ago Justin Swanhart Swanhart

Hi,

You can support the second requirement by using SELECT .. INTO OUTFILE. You could see that the query is in RUNNING state, then open the file in PHP, which will not be completely written until the query completes. This will allow you to get the results in an unbuffered fashion.

To do this with ASYNC, add a hint to the beginning of the query: call async.queue('/*+unbuffered*/select * from mysql.user into outfile "/tmp/test2.txt"');

If you combine that with a UDF to erase the files (there is one in https://github.com/greenlion/Fastbit_UDF called fb_unlink()) this could be a very workable solution to your problem.

 
8 years, 9 months ago Michael Shestero

It's not useful to do temporary files in multiuser multitask system.

I know one better way to do the task: you can do unbuffered reading in a separate second PHP scipt and call it from the main script by HTTP (using localhost). Then you can read its TCP-socket asynchronous (it's also not graceful in PHP, but possible).

Node.JS support async requests to MySQL (through new MariaDB clent API). Does anybody know if it's possible to ineract from PHP to Node.JS in a async non-blocking way?

 
8 years, 9 months ago Justin Swanhart Swanhart

yes it is useful. you assign a random filename then you poll it. but do what you want, the solution I proposed will work just fine

 
8 years, 9 months ago Justin Swanhart Swanhart

Oh, one more thing, you will need to write the file to a shared filesystem if you aren't running the PHP client on the same machine as the server, but this is trivial. You could use CIFS or NFS for example.

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.