dongliang1223 2014-05-07 06:46
浏览 44

将JOIN查询结果作为JSON返回

I am using a php web service to return SQL queries results to android in a JSON object format. It works fine for me but now I want to be able to return the result of a Joint query in a JSON Object, and I don't know how to do it. how would be able to put all the result in a JSON object and how do I access the result if I select data from two tables via a INNER JOIN?

EDIT : HERE IS THE QUERY $query = " SELECT * FROM question INNER JOIN comment ON question.id = comment.id_question WHERE question.id = :id";

WHy question is : this does return all I need and I encode it using json_encode. But when I receive it on my Android side, how to I access columns from table question or from table comment knowing that all I have is one json Object, let's said called "json".

  • 写回答

1条回答 默认 最新

  • douou5933 2014-05-07 08:35
    关注

    try using json_encode($result) in the PHP side. Then parse it on the other side.

    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b