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

  }

}

原文地址:https://www.cnblogs.com/gyzown/p/6897181.html