【发布时间】:2013-03-23 01:28:17
【问题描述】:
我正在编写一个 TYPO3 - 网站扩展程序。因为我使用的是 Extbase 框架,所以我有一个存储库类 (Tx_Extbase_Persistence_Repository),我在其中连续执行两个 sql 查询:
$query1 = $this->createQuery();
$query1->statement($sql1);
$res1 = $query1->execute();
$query2 = $this->createQuery();
$query2->statement($sql2);
$res1 = $query2->execute();
$res1 和$res2 都包含Tx_Extbase_Persistence_QueryResult。现在我想返回组合结果,但我不知道这是如何完成的。返回原始数组不是一个选项,因为我依赖于QueryResult 类的函数,而且我想避免组合 sql(UNION, JOIN)。我已经试过了:
$myResult = $this->objectManager->create('Tx_Extbase_Persistence_ObjectStorage')
foreach($res1 as $obj) {
$myResult->attach($obj);
}
//foreach $res2
..但这会引发错误 ("could not determine the child object type")
那么如何正确组合两个Tx_Extbase_Persistence_QueryResult?
编辑:
我的意思是合并不是两个单独的QueryResults,我只想要一个包含$query1 和$query2 的结果。不幸的是,SQL-UNION 或 JOIN 不是一个选项。
【问题讨论】:
标签: php typo3 extbase typo3-flow