PHP script in permanent process?

0

Friends, how are you? Nice to say hello, I'm here again making a query about php (I'm a novice in programming). I'm trying to do something (which I do not know if I can) with PHP, I hope you can help me.

What I need is that with a MYSQL query made from php, several records will be obtained and those records will be stored as a file within a directory. My idea is that if MYSQL gets 1000 results, the files will be created 1 by 1, since, when a record appears in that folder another process that will be running permanently, will take it and process it.

Result 1 - 1000 mysql:  result 1 - > file 1 - > process is processed and finished continue php with: result 2 ... and so on until the records are finished.

I'm currently doing the following:

 $select = "SELECT * FROM tabla1 where dato = 'dato'";
 $select = mysql_query($select, $link);
 while($row=mysql_fetch_array($select){
     $dato=$row['dato'];
 $ext1 = fopen("/usr/src/test/test.txt", "a+");
 $contenido="este es el archivo que sera procesado con los datos $datos";
 fwrite($ext1,$contenido);
 fclose($ext1);     
 }

Here I already have the problem, since when doing that, it creates all the files in the folder at the same time. that is, the 1000 records. I do not know how to make PHP stay in the loop waiting for the response of the other process. It could also be that at the end of the other process, create a file or record in another directory and php (script1 to see that continue)

I hope you have understood, and if someone can help me, I thank you very much already.

    
asked by Lusag silva 25.04.2018 в 20:32
source

0 answers