0

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

我的问题是 in() 函数。假设我有一个“任务”对象,每个任务都有一个“状态”对象(多对一)。现在我想让所有任务的状态为“false”的“show”属性。那是行不通的:

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

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

感谢帮助。

4

3 回答 3

0

它应该像这样工作(假设状态对象集不为空):

$query = $this->createQuery();
$query->matching($query->in('status', $this->statusRepository->findByShow(FALSE)));
return $query->execute();
于 2013-07-25T21:44:43.500 回答
0

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

$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 类必须实现以下内容:

public getIdentifier(){ return $this->Persistence_Object_Identifier; }
于 2014-01-08T12:49:51.360 回答
0

当调用findByShow时,它返回一个QueryResult对象,“in”方法中的第二个参数应该是一个混合元素的数组。

尝试使用 QueryResult 的 toArray() 方法将您的对象转换为您的状态模型的数组。

$this->statusRepository->findByShow(FALSE)->toArray();

我希望它有帮助!
奥利维尔

于 2013-08-05T17:10:39.340 回答