PDO 语句转 JSON
本文介绍了PDO 语句转 JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将 PDOStatement
转换为 JSON?
How would I convert a PDOStatement
to JSON?
我需要对 PDO::FETCH_OBJ
进行 jsonify.
I need to jsonify a PDO::FETCH_OBJ
.
json_encode
无法对 PDO::FETCH_OBJ
进行 jsonify.
json_encode
does not have the ability to jsonify a PDO::FETCH_OBJ
.
推荐答案
您可以使用内置的 php 函数 json_encode() http://php.net/manual/en/function.json-encode.php
You can use the inbuilt php function json_encode() http://php.net/manual/en/function.json-encode.php
要对结果进行编码,请使用类似
To encode the results use something like
这篇关于PDO 语句转 JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!