I have mysql db with column that called "info", this is json column.
I have there this json:
{
"pizza":{
"sugar":"yes",
"calorie":"100",
"protein":"no"
},
"hamburger":{
"sugar":"no",
"calorie":"120",
"protein":"yes"
}
}
when I want to update for example the calorie of the pizza there is no problem:
DB::table('food')->where('id', '=', '1')
->update(array('info->pizza->calorie' => '90'));
then in the db i have:
{
"pizza":{
"sugar":"yes",
"calorie":"90",
"protein":"no"
},
"hamburger":{
"sugar":"no",
"calorie":"120",
"protein":"yes"
}
}
but when i want to add some food, for example chocolate:
DB::table('food')->where('id', '=', '1')
->update(array('info->chocolate->calorie' => '10'));
nothing happened.
In which way I can do that? thanks!
pizzaobject, but I don't see achocolateobject anywhere in your code.