I need to call a function in PHP that writes several records in the database which will take a lot, I need to do it in the background while PHP does something else, is it possible? If so, how?
I need to call a function in PHP that writes several records in the database which will take a lot, I need to do it in the background while PHP does something else, is it possible? If so, how?
You can use the PHP Thread class:
<?php
class segundoPlano extends Thread
{
public function __construct($sP)
{
$this->sP = $sP;
}
public function run()
{
//o teu código a executar;
}
}
$segundoP = new segundoPlano($sP);
$segundoP->start();
The variable in the constructor is an example.
Note: To use this class you must install the pthreads extension .