Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/82.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
Sql symfony与DQL_Sql_Symfony_Dql - Fatal编程技术网

Sql symfony与DQL

Sql symfony与DQL,sql,symfony,dql,Sql,Symfony,Dql,我有: public function findTodasLasCompras($usuario_id) { $em = $this->getEntityManager(); $dql = 'SELECT v, o, t FROM OfertaBundle:Venta v JOIN v.oferta o JOIN o.tienda t WHERE v.usuario = :id

我有:

public function findTodasLasCompras($usuario_id)
{
    $em = $this->getEntityManager();
    $dql = 'SELECT v, o, t
            FROM OfertaBundle:Venta v
            JOIN v.oferta o
            JOIN o.tienda t
            WHERE v.usuario = :id
            ORDER BY v.fecha DESC';

    $consulta = $em->createQuery($dql);
    $consulta->setParameter('id', $usuario_id);
    $result = $consulta->getResult();
    return $consulta->getResult();
}
当我执行时,它会失败,并出现错误:

ContextErrorException:注意:未定义索引:C:\wamp\www\symony\vendor\doctrine\orm\lib\doctrine\orm\Internal\Hydration\ObjectHydrator.php第477行中的Cupon\OfertaBundle\Entity\Oferta

在C:\wamp\www\symony\vendor\doctrine\orm\lib\doctrine\orm\Internal\Hydration\ObjectHydrator.php第477行中 在ErrorHandler->handle('8',未定义索引:Cupon\OfertaBundle\Entity\Oferta'


帮助!请!谢谢

尝试将您的“加入”转换为“左加入”


如果一个usario使用id 8存在,可能他没有链接到oferta或tienda,因此连接不会返回任何内容,而是留下join keep usario实例。

首先,替换此:

$result = $consulta->getResult();
return $consulta->getResult();
为此:

$result = $consulta->getResult();
return $result;
也许你应该重新安装Symphony,好像有东西坏了