//对汉字编码
private function url_encode($str) { if(is_array($str)) { foreach($str as $key=>$value) { $str[urlencode($key)] = url_encode($value); } } else { $str = urlencode($str); } return $str; } //错误信息记录 private function func_err($msg,$data,$cate) { //咨询 $data['author'] = $this->url_encode($data['author']); //病种 $data['disease'] = $this->url_encode($data['disease']); //$this->url_encode('sdfsd'); //将数据json化 $data = json_encode($data); //当前添加时间 $time = date("Y-m-d H:i:s",time()); //编辑sql语句 $sql = "insert into patient_arrive_err(msg,data,cate,create_time) values ('{$msg}','{$data}','{$cate}','{$time}')"; //保存信息 $this->db->query($sql); }
- function encode_json($str) {
- return urldecode(json_encode(url_encode($str)));
- }
- /**
- *
- */
- function url_encode($str) {
- if(is_array($str)) {
- foreach($str as $key=>$value) {
- $str[urlencode($key)] = url_encode($value);
- }
- } else {
- $str = urlencode($str);
- }
- return $str;