PHP MySql 模糊查询json数据

一般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格式的数据

猜你喜欢

转载自blog.csdn.net/leyangjun/article/details/80348758
今日推荐