如果您使用来自Typo3或Flow3的QueryInterface,您可以在QueryInterface Extbase Dokumentation中查找您可以使用的所有函数。我已经在Flow3中创建了一些and,OR和LogicalNOT,它们工作得很好。
我的问题是in()函数。假设我有一个" task“对象,每个任务都有一个"status”对象(多对一)。现在,我希望所有任务的状态都是“show”属性为“false”。这就是不起作用的地方:
$query->in('status',$this->statusRepository->findByShow(FALSE));我猜这是因为find()的返回值类型。您可以获取“NULL”,一个对象或数组中的多个对象。但是为什么它不能工作,我如何修复它呢?
谢谢你的帮助。
发布于 2013-07-26 05:44:44
它应该是这样工作的(假设状态对象集不为空):
$query = $this->createQuery();
$query->matching($query->in('status', $this->statusRepository->findByShow(FALSE)));
return $query->execute();发布于 2013-08-06 01:10:39
当你调用findByShow时,它返回一个QueryResult的对象," in“方法中的第二个参数应该是一个混合元素数组。
尝试使用QueryResult的toArray()方法将对象转换为状态模型的数组。
$this->statusRepository->findByShow(FALSE)->toArray();我希望它能帮上忙!
奥利维尔
发布于 2014-01-08 20:49:51
我不确定他们现在是否解决了这个问题,但我记得去年我花了几个小时才发现我必须这么做:
$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; }https://stackoverflow.com/questions/17864051
复制相似问题