Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php in()方法-Typo3-queryInterface_Php_Doctrine Orm_Typo3_Extbase_Typo3 Flow - Fatal编程技术网

Php in()方法-Typo3-queryInterface

Php in()方法-Typo3-queryInterface,php,doctrine-orm,typo3,extbase,typo3-flow,Php,Doctrine Orm,Typo3,Extbase,Typo3 Flow,如果使用Typo3或Flow3中的QueryInterface,则可以在中查找可以使用的所有函数。我已经在Flow3中创建了一些and、OR和LogicalNot,它们工作得很好 我的问题是in()函数。假设我有一个“任务”对象,每个任务都有一个“状态”对象(多对一)。现在,我想让所有任务的状态为'false'上的'show'属性。这就是不起作用的地方: $query->in('status',$this->statusRepository->findByShow(FALSE)

如果使用Typo3或Flow3中的QueryInterface,则可以在中查找可以使用的所有函数。我已经在Flow3中创建了一些and、OR和LogicalNot,它们工作得很好

我的问题是in()函数。假设我有一个“任务”对象,每个任务都有一个“状态”对象(多对一)。现在,我想让所有任务的状态为'false'上的'show'属性。这就是不起作用的地方:

$query->in('status',$this->statusRepository->findByShow(FALSE));
我想这是因为find()的返回值类型。您可以在一个数组中获取一个或多个“NULL”对象。但是为什么它不起作用,我怎么能修复它呢

谢谢您的帮助。

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


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

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

$this->statusRepository->findByShow(FALSE)->toArray();
我希望有帮助

Olivier

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

$statusIds = Array();
$status = $this->statusRepository->findByShow(FALSE);
foreach($status as $s) $statusIds[] = $status->getIdentifier();
$constraint = $query->in('status',$statusIds);
return $query->matching($constraint)->execute();
您的状态类必须实现以下功能:

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

这就是我准备好的。。。如果我将对查找进行count(),如果它是0,则什么也不做,如果它是1,则表示等于()并且在()中有多个状态实体,您会怎么说?他无法生成查询字符串。。。toString()中的错误您可以复制并粘贴完整的错误消息吗?如果您总是只提供少量代码或错误,这对找到解决方案并没有真正的帮助。
致命错误:Method Doctrine\ORM\Query\Expr\Func::\uuu toString()不能在第0行的C:\xampp\htdocs\Packages\Framework\doctor.ORM\Classes\Query\Expr\Func.php中引发异常
您搜索过吗?我在中找到了您确切的错误消息(
致命错误:Method-Doctrine\ORM\Query\Expr\Func::\uu-toString()不能引发异常
),下面的某个地方有一个
它现在可以工作了,我必须…
。你试过了吗?
public getIdentifier(){ return $this->Persistence_Object_Identifier; }