[英]Typo3 Extbase How can I get all Objects with a relation = x?
I want to use Extbase on my Project. 我想在我的项目上使用Extbase。 But I don't get this query to Work:
但是我没有让这个查询工作:
SELECT
tx_domain_model_A.*,
tx_domain_model_B.*
FROM
tx_domain_model_A LEFT JOIN tx_domain_model_B ON (tx_domain_model_B.uid IN (tx_domain_model_A.b_I_D))
WHERE
tx_domain_model_B.von >= ?
ORDER BY tx_domain_model_B.von
The result should like this: 结果应如下所示:
A.uid A.b_I_D B.uid B.von
1 5,8,3 5 abc
1 5,8,3 8 def
1 5,8,3 3 ghi
2 1,2 1 123
2 1,2 2 456
3 1 1 123
I use: 我用:
$query = $this->createQuery();
$query->matching($query->greaterThanOrEqual('bID.von',date('U')));
But then, all Child Objects are empty. 但是,所有子对象都是空的。 I think this comes from: http://fossies.org/dox/typo3_src-6.2.9/Typo3DbQueryParser_8php_source.html
我认为这来自: http : //fossies.org/dox/typo3_src-6.2.9/Typo3DbQueryParser_8php_source.html
function addUnionStatement ...
...
// TODO check if there is another solution for this
785 $sql['keywords']['distinct'] = 'DISTINCT';
So I do it with a $query->statement(...)
but this don't work too. 所以我用
$query->statement(...)
做到这一点,但这也不起作用。
I want to get all Objects from Table A which have A.B_I_D.von
bigger than today. 我想从表A中获取所有具有比今天更大的
A.B_I_D.von
对象。 Table B (= A.B_I_D
) is an n:1 relation ( A=n:B=1
). 表B(=
A.B_I_D
)是n:1关系( A=n:B=1
)。 How can I get an Object from A more than one time? 如何多次从A获取对象? And can use it in Fluid?
可以在Fluid中使用吗?
I use Typo3 6.2 我使用Typo3 6.2
ok first of all extbase queries will always give you full objects as a result. 好吧,首先,extbase查询将始终为您提供完整的对象。 that is why you need to use
statement
to achive your goal. 这就是为什么您需要使用
statement
来达到目标的原因。 The second trick to get the result as you want is that you need to set to receive result as a array. 获得所需结果的第二个技巧是需要设置为以数组形式接收结果。 It is needed beacause extbase is trying to map your statement to object of model related with repository
因为extbase试图将您的语句映射到与存储库相关的模型对象,所以需要它
you can change the type of return data using setReturnRawQueryResult
: you can read more about it here http://docs.typo3.org/typo3cms/ExtbaseFluidBook/6-Persistence/3-implement-individual-database-queries.html 您可以使用
setReturnRawQueryResult
更改返回数据的类型:您可以在此处详细了解http://docs.typo3.org/typo3cms/ExtbaseFluidBook/6-Persistence/3-implement-individual-database-queries.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.