如何从sql查询中取消序列化数据并用json解析它们

ndasle7k  于 2021-06-18  发布在  Mysql
关注(0)|答案(0)|浏览(273)

我有上面的php代码,以便从mysql数据库中提取数据并将它们解析为json。

$BusinessProductsData ='';
        $sql = "SELECT t1.meta_value, t1.post_id FROM `f2st_postmeta` AS t1 
                INNER JOIN
                (SELECT post_title AS post_title, ID FROM `f2st_posts` WHERE post_type='restaurants' and post_status='publish') AS t2
                ON t1.post_id=t2.ID
                WHERE t1.meta_key='foodbakery_menu_items'";

        mysqli_set_charset($dbConnection, "utf8");

        $result = mysqli_query($dbConnection, $sql);

        while ($row = mysqli_fetch_assoc($result)){
            $json_array[] = $row;
        }

        $BusinessProductsData = json_encode($json_array);
        echo $BusinessProductsData;

不幸的是,meta\u值已经序列化了如下值 {"meta_value":"a:2:{i:0;a:7:{s:15:\"menu_item_title\";s:89:\"Dr. Scholl Fungal Nail Treatment \u03a3\u03cd\u03c3\u03c4\u03b7\u03bc\u03b1 \u0391\u03bd\u03c4\u03b9\u03bc\u03b5\u03c4\u03ce\u03c0\u03b9\u03c3\u03b7\u03c2 \u039c\u03c5\u03ba\u03ae\u03c4\u03c9\u03bd\";s:15:\"restaurant_menu\";s:27:\"\u0395\u03af\u03b4\u03b7 \u03a6\u03c1\u03bf\u03bd\u03c4\u03af\u03b4\u03b1\u03c2\";s:21:\"menu_item_description\";s:0:\"\";s:14:\"menu_item_icon\";s:5:\"16665\";s:15:\"menu_item_nutri\";s:0:\"\";s:15:\"menu_item_price\";s:5:\"15.12\";s:15:\"menu_item_extra\";s:0:\"\";}i:1;a:7:{s:15:\"menu_item_title\";s:61:\"Optima Aloe Pura Aloe Vera Gel 200ml \u0396\u03b5\u03bb \u0391\u03bb\u03cc\u03b7 \u0392\u03ad\u03c1\u03b1\";s:15:\"restaurant_menu\";s:25:\"\u0395\u03af\u03b4\u03b7 \u039f\u03bc\u03bf\u03c1\u03c6\u03af\u03b1\u03c2\";s:21:\"menu_item_description\";s:0:\"\";s:14:\"menu_item_icon\";s:5:\"16666\";s:15:\"menu_item_nutri\";s:0:\"\";s:15:\"menu_item_price\";s:4:\"6.86\";s:15:\"menu_item_extra\";s:0:\"\";}}","post_id":"16220"},{"meta_value":"a:0:{}","post_id":"16331"} 如何取消meta\u值的序列化?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题