我的PHP Thread类有问题,虽然我在构造函数的$this->mysqli
上指出$mysqli
变量我在该类的函数中得到NULL
该变量。
class Process extends Thread {
protected $counter;
protected $mysqli;
public function __construct($name, Counter $counter, $mysqli )
{
var_dump($mysqli); // here connection exist
$this->name = $name;
$this->counter = $counter;
$this->mysqli = $mysqli;
}
public function run() {
var_dump($this->mysqli); // here connection doesn't exist (empty mysqli object)
$address = new Link($this->mysqli, $this->name);
$address->insertName($this->name);
}
}