您可以使用内置的php函数json_enpre()
要对结果进行编码,请使用类似
<?php$pdo = new PDO("mysql:dbname=database;host=127.0.0.1", "user", "password");$statement = $pdo->prepare("SELECt * FROM table");$statement->execute();$results = $statement->fetchAll(PDO::FETCH_ASSOC);$json = json_enpre($results);

![JSON的PDOStatement [关闭] JSON的PDOStatement [关闭]](http://www.mshxw.com/aiimages/31/465935.png)
