首页 > 代码库 > 封装JSON

封装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;

  }

}

封装JSON