I have CActiveRecord model Game which attribute game_data stores the data of the game. In such way I stored the data (within beforeSave method):
$this->data = gzcompress(json_encode($this->data));
I extract data in the following way(withinn afterFind method):
$this->data = json_decode(gzuncompress($this->data), true);
After that I want to manipulate with the game_data attribute(add/change/delete), but the code returned an unexpected result for me. Code and my research:
var_dump($this->data); // data that already stored in db for this game
array(1) {
["provably_fair"]=>
array(1) {
["server_seed"]=>
string(32) "dKOsfTsGvmvZe0VW6bcFnIhJKXDesKeM"
}
}
I am trying to add new property and value:
$this->data['provably_fair']['client_seed'] = $clientSeed;
But content of $this->data not change:
var_dump($this->data);
array(1) {
["provably_fair"]=>
array(1) {
["server_seed"]=>
string(32) "dKOsfTsGvmvZe0VW6bcFnIhJKXDesKeM"
}
}
How I can modify data of this CActiveRecord attribute and whether it is possible?