doutan5798 2014-10-04 15:48 采纳率: 100%
浏览 40
已采纳

ZF2:TableGateway ResultSet到JSON

I am trying to return data from my database to JSON in Zend Framework 2. I am using a TableGateway right now and it returns a ResultSet. But the JsonModel cannot show the resultset. So is there a way to convert it, or is there an other way to access my database?

The IndexAction in the HomeController

public function indexAction()
{
    return new JsonModel(array(
        'posts' => $posts,
        'resources' => $resources,
        'style' => $style,
        'imgStyle' => $imgStyle,
        'success' => true,
    ));
}

The function that returns the resultset

public function fetchAll()
{
    $resultSet = $this->tableGateway->select(function (Select $select) {
        $select->order('date DESC');
    });
    return $resultSet;
}
  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 win10账户不见了怎么找回
      • ¥15 如何显示得分大于0.5的检测框
      • ¥15 微信小游戏使用云开发的CDN配置
      • ¥15 Matlab的SAW模态耦合模型的仿真程序
      • ¥20 求个C# SSL socket的客户端和 服务端代码
      • ¥15 大家调试TI C2000系列DSP用什么上位机?
      • ¥20 Eltable 如何实现鼠标拖拽范围多选
      • ¥15 产品需要了解什么代码技术才能更好站在开发角度思考问题?
      • ¥15 pandas 处理表格计算 帮助
      • ¥15 统计数据能提前统计吗