class Test extends thread {
function __construct(&$db,$userObj) {
$this -> userObj = $userObj;
print "Original:";
var_dump($db);
$this->db = $db;
print "InThread:";
var_dump($this->db);
// as value of $this->db and db(in constructor) is different I am gettting different values.
}
public function run(){
$userId = $this->userObj->getUserId();
$data = $this->db->getData();
// as value of $this->db and db(in constructor) is different I am getting different values.
}
function getData(&$db,$userObj){
$thread = new Test($db,$userObj);
$thread->start();
}
I want to use the value of db in my run function. How to access thread constructor variable via run() without changing $db values.