douchuanchai2793 2011-05-24 11:39
浏览 26
已采纳

在执行UNION查询时,如何让Zend Db返回行集而不是数组?

I have a result set that is the result of a MySQL UNION query. The code I am using to fetch the data is:

$union_select = $PagesTable->getAdapter()->select()
        ->union(array('(' . $legal_resources_select . ')', '(' . $pages_select . ')'));
$PagesTable->getAdapter()->fetchAll($union_select)

$PagesTable extends Zend_Db_Table_Abstract. The full select is too big to post here and I don't think it is relevant to this particular question. If I am wrong let me know.

Currently this is returning an array of results, but I want it to return a rowset object. I must also be able to specify the $_rowClass. This is necessary so I can add methods for formatting and manipulating the returned values.

Is this possible?

  • 写回答

3条回答 默认 最新

  • dongwende1984 2011-05-24 11:55
    关注

    You cannot. The result set you are fetching is a composite, and not a set of Rows from the DB, so even if it were possible, its a pretty bad idea.

    Zend_Db_Table is an implementation of the Table Data Gateway pattern more than Active Record.

    What you describe would be possible usually under Active Record, and to do so, I'd suggest looking at Doctrine 1.2 rather than Zend_Db_Table.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了