简体   繁体   English

如何更新数据库中数组的值

[英]How can I update value of array in database

I am retriving following data from the database.When I do print_r , it gives me follwing result. 我正在从数据库中检索以下数据。当我执行print_r ,它给了我以下结果。

Array ( [0] => stdClass Object ( [params] => {"size":"980|*|485|*|1","responsive":"1|*|0","align":"normal","autoplay":"1|*|6000" } ) )

Now I want to change the value of autoplay (which is last in this array) in it.How can I do that with the update query ? 现在我想在其中更改自动播放的值(此数组中的最后一个),如何使用update查询来做到这一点?

NOTE: Field name is param in database and table name is xyz. 注意:字段名称是数据库中的param ,表名称是xyz。

As stated, your params is a json object. 如前所述,您的params是一个json对象。 You need to decode that object so that you can use it. 您需要对该对象进行解码,以便可以使用它。

$data = json_decode($item[0]->params);

$data->autoplay = 'New VALUE';

Example

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM