微信开发大坑之数据无法正常存储至数据库

在做微信语音识别时,需要将用户的聊天和语音记录存储到数据库中

</pre><pre name="code" class="php">        $openid = trim($object->FromUserName);
        $media_id = trim($object->MediaId);
        $create_time = trim($object->CreateTime);
        $voice_text = trim($object->Recognition);

        $data                = array();
        $data['user_id']     = D('User')->getUseridByOpenid($openid);
        $data['voice']       = D('Weixin')->saveMedia($media_id);
        $data['voice_text']  = $voice_text ? $voice_text:'1';
        $data['status']      = 0;
        $data['create_time'] = $create_time ? $create_time : 222;
        $data['update_time'] = time();

        $rs = M('Voice')->add($data);


请将受到的数据进行trim处理,不然你就等着哭吧,不多说了,都是泪

你可能感兴趣的:(微信开发大坑之数据无法正常存储至数据库)