封装JSON

Posted 繁华似水

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了封装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的主要内容,如果未能解决你的问题,请参考以下文章