php json 写入 mysql 的例子

时间:2022-07-22 17:40:47

$a['aaa']='aaaa';
$a['bbb']='bbb';
$a['ccc']='ccc';

$arr['step_name']='kfkf';
$arr['process_name']='ififififiif';
$arr['id']='jjjjad';
$arr['task_data'] = addslashes(json_encode($a));

$m=M('wf_tasks');
//$m->add($arr);
$data = $m->where('id="jjjjad"')->find();
$aa=stripslashes($data['task_data']);
$bb=json_decode($aa,true);//不加true,则返回为object
var_dump($bb);
//echo $bb['aaa'];
return;