class Field extends Thread{
public $dataFields;
public function addValue($table,$key,$data){
print_r($this->dataFields[$table]);
echo "\ndata: ".$data."\n";
if(isset($this->dataFields[$table][$key])){
$this->dataFields[$table][$key]= $data;
echo "yes\n";
}
else echo "no\n";
print_r($this->dataFields[$table]);
}
public function setVariables($con){
$result = mysqli_query($con,"select * from property,city limit 1");
$row=mysqli_fetch_fields($result);
foreach ($row as $key => $value) {
$propData[$value->table][$value->name]="";
}
$propData["property"]["portalId"]=2;
$propData["property"]["area"]="delhi";
$this->dataFields=$propData;
$this->addValue("property","id","1");
//print_r($this->dataFields);
$this->dataFields["property"]["id"]=1;
var_dump($propData);
var_dump($this->dataFields);
}
}
as you can see the code I am updating the value of array through function addValue, if the key is set in the dataFields array then it will get updated but in this its not happening when I try to call the function:
addValue("property","id","1"); through function setVariables() (see the output below)
it prints the value of $data it prints "yes". The class variable dataFields is not getting updated.
[Edit] When I am using Threads extended class it don't get updated but when I don't use Thread extended class then it get updated.
Array
(
[id] =>
[portalId] => 2
[area] => delhi
)
data: 1
yes
Array
(
[id] =>
[portalId] => 2
[area] => delhi
)
array(2) {
["city"]=>
array(3) {
["id"]=>
string(0) ""
["name"]=>
string(0) ""
["otherNames"]=>
string(0) ""
}
["property"]=>
array(3) {
["id"]=>
string(0) ""
["portalId"]=>
int(2)
["area"]=>
string(5) "delhi"
}
}
array(2) {
["city"]=>
array(3) {
["id"]=>
string(0) ""
["name"]=>
string(0) ""
["otherNames"]=>
string(0) ""
}
["property"]=>
array(3) {
["id"]=>
string(0) ""
["portalId"]=>
int(2)
["area"]=>
string(5) "delhi"
}
}
data: DEFAULTand notdata: 1? Please show us the full codeaddValue("property","id","1");->$this->addValue("property","id","1");does that do the trick for you?print_r()calls tovar_dump()and look into the source code if there are any "hidden" characters