phpcms调用getJSON无法返回json数据的解决方法

phpcms教程 强烈建议 2024-03-02 10:43 144 0

  public function public_mobile_getjson_ids() {//publc是后来加上去的

  $modelid = intval($_GET['modelid']);

  $id = intval($_GET['id']);

  $this->db->set_model($modelid);

  $tablename = $this->db->table_name;

  $this->db->table_name = $tablename.'_data';

  $r = $this->db->get_one(array('id'=>$id),'mobile_type');

  if($r['mobile_type']) {

  $relation = str_replace('|', ',', $r['mobile_type']);

  $relation = trim($relation,',');

  $where = "id IN($relation)";

  $infos = array();

  $this->mobile_db = pc_base::load_model ( 'mobile_type_model' );

  $datas = $this->mobile_db->select($where,'id,type_name');

  //$this->db->table_name = $tablename;

  //$datas = $this->db->select($where,'id,title');

  foreach($datas as $_v) {

  $_v['sid'] = 'v'.$_v['id'];

  if(strtolower(CHARSET)=='gbk') $_v['type_name'] = iconv('gbk', 'utf-8', $_v['type_name']);

  $infos[] = $_v;

  }

  echo json_encode($infos);

  }

  }

本站资源均来自互联网或会员发布,如果不小心侵犯了您的权益请与我们联系。我们将立即删除!谢谢!