一般json格式的数据会对中文进行特殊处理,所以查询的时候需要处理下才行
$name = "乐杨俊";
$json_name=str_replace("\\","_",json_encode($name));
$where .= " and extend_params like '%" . $json_name ."%' ";
eg:语句出来后是这种格式: select * from user where name like '%"_u533b_u6e21_u4e913"%'
这样就能查询mysql存储为json格式的数据

本文介绍了一种处理JSON格式数据中中文字符的方法,通过使用str_replace和json_encode函数组合,实现对MySQL中存储的JSON数据的有效查询。
1004





