php使用数据库上的另一列序列化数据
我有一个allin表,里面有序列化的数据和像这样的年份php使用数据库上的另一列序列化数据,php,mysql,Php,Mysql,我有一个allin表,里面有序列化的数据和像这样的年份 <pre> +------+--------+------------------------------------------------+ | id | year | data | +------+--------+------------------------------------------------+ | 1 |
<pre>
+------+--------+------------------------------------------------+
| id | year | data |
+------+--------+------------------------------------------------+
| 1 | 2017 | a:2:{s:3:"foo";s:1:"1";s:3:"bar";s:1:"2";} |
+------+--------+------------------------------------------------+
| 2 | 2018 | a:2:{s:3:"foo";s:1:"3";s:3:"bar";s:1:"4";} |
+------+--------+------------------------------------------------+
from:
array("foo"=>"1","bar"=>"2"); //2017
array("foo"=>"3","bar"=>"4"); //2018
</pre>
这是我的密码
$data = unserialize($db);
我如何在2018年和2017年选择foo和bar
谢谢您可以更改
$data[$row["year"]] = unserialize($db);
到
通过
$data[$row["year"]] = unserialize($db);
echo $data[2017]["foo"];