封装JSON

function JSONQuery($sql,$type=1)

{

  $db = new MySQLi($this->host,$this->uid,$this->pwd,$this->dbname);

  $r = $db->query($sql);

  if($type == 1)

  {

    return json_encode($r->fetch_all(MYSQLI_ASSOC));

  }

  else

  {

    return $r;

  }

}

posted @ 2017-05-24 08:53  繁华似水  阅读(136)  评论(0编辑  收藏  举报