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」 –