Php 如何将Doctrine resultset转换为数组?

Php 如何将Doctrine resultset转换为数组?,php,doctrine,doctrine-orm,Php,Doctrine,Doctrine Orm,我使用以下命令获得一个结果集: $em = $this->getDoctrine()->getEntityManager(); $test = $em->getRepository('RestWebServiceBundle:Test')->findall(); 如何将$test转换为数组 toArray似乎不起作用。我相信有一种水合模式可以生成数组而不是对象: 假设findall方法没有被重写,那么您使用:Query::hydrome\u ARRAY $test

我使用以下命令获得一个结果集:

$em = $this->getDoctrine()->getEntityManager();
  $test = $em->getRepository('RestWebServiceBundle:Test')->findall();
如何将$test转换为数组


toArray似乎不起作用。

我相信有一种水合模式可以生成数组而不是对象:

假设findall方法没有被重写,那么您使用:
Query::hydrome\u ARRAY

$test = $em->getRepository('RestWebServiceBundle:Test')->findall(Query::HYDRATE_ARRAY);
如果它被覆盖,您可以在
getResult
调用中将其用作参数

Doctrine2手册中的示例:

$users = $query->getResult(Query::HYDRATE_ARRAY);
请看这里:

我相信有一种水合模式可以生成数组而不是对象:

假设findall方法没有被重写,那么您使用:
Query::hydrome\u ARRAY

$test = $em->getRepository('RestWebServiceBundle:Test')->findall(Query::HYDRATE_ARRAY);
如果它被覆盖,您可以在
getResult
调用中将其用作参数

Doctrine2手册中的示例:

$users = $query->getResult(Query::HYDRATE_ARRAY);
请看这里:

@MarinSagovac谢谢。链接已修复。@MarinSagovac谢谢。链接已修复。