in()方法-Typo3-queryInterface [英] in() method - Typo3 - queryInterface

查看:78
本文介绍了in()方法-Typo3-queryInterface的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您使用Typo3或Flow3中的QueryInterface,则可以在 QueryInterface Extbase文档以获取所有可以使用的功能。我已经在Flow3中创建了一些AND,OR和LogicalNOT,它们工作得很好。

if you use the QueryInterface from Typo3 or Flow3 you can look up in the QueryInterface Extbase Dokumentation for all functions you can use. I already created some ANDs, ORs and LogicalNOTs in Flow3 and they work great.

我的问题是in()函数。假设我有一个任务对象,每个任务都有一个状态对象(多对一)。现在,我希望所有任务的状态都为假的显示属性。那是行不通的:

My problem is the in() function. Let's say I have a "task" object and every task has one "status" object (over Many-To-One). Now I want to have all tasks having a status with the 'show' attribute on 'false'. That's what doesn't work:

$query->in('status',$this->statusRepository->findByShow(FALSE));

我想这是因为find()的返回值类型。您可以获取 NULL,数组中的一个或多个对象。但是,为什么它不起作用以及如何解决呢?

I guess it's because of the return value types of find(). You can get 'NULL', one object or many objects in an array. But why it doesn't work and how can I fix it?

感谢帮助。

推荐答案

我不确定他们是否现在已解决此问题,但我记得去年花了几个小时才发现必须这样做:

I'm not sure if they fixed this by now but I remember spending hours last year to find out I had to do this:

$statusIds = Array();
$status = $this->statusRepository->findByShow(FALSE);
foreach($status as $s) $statusIds[] = $status->getIdentifier();
$constraint = $query->in('status',$statusIds);
return $query->matching($constraint)->execute();

您的Status类必须实现以下内容:

Your Status class must implement the following:

public getIdentifier(){ return $this->Persistence_Object_Identifier; }

这篇关于in()方法-Typo3-queryInterface的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆