1
嗨我试图插入到我的MySQL数据库json数组。从Android客户端数组json数据。如何将json数组数据插入到mysql中?
{"message":[ {"body":"Fdsa","_id":"114","status":"-1","address":"null","read":"1","type":"3","date":"1429781969573","thread_id":"2"},{"body":"wtf2","_id":"113","status":"0","address":"","read":"1","type":"1","date":"1429590050090","thread_id":"1"}, {"body":"wtf2","_id":"112","status":"0","address":"","read":"1","type":"1","date":"1429590050090","thread_id":"1"}]}
如何解析json数据到数据库中?
$message_data = json_decode($data,true);
printf($message_data['message']);die;
哪里是MySQL的代码? – Raptor
一旦你用这个'true'标志解码了JSON字符串,它就会成为你的普通数组。就像平常一样对待它,并使用PDO或MySQLi API来插入 – Ghost
,但不解析字符串“message” –