Foros del Web » Programando para Internet » PHP » Zend »

Error en DQL

Estas en el tema de Error en DQL en el foro de Zend en Foros del Web. Hola: Tengo este DQL que me da error: Código PHP: $role  =  $this -> em -> createQuery ( 'SELECT h.role FROM Application\Entity\Histousuario h WHERE (h.id = :id)' ); $role -> setParameters (array(      ...
  #1 (permalink)  
Antiguo 17/05/2013, 12:14
 
Fecha de Ingreso: enero-2010
Mensajes: 491
Antigüedad: 14 años, 3 meses
Puntos: 12
Error en DQL

Hola:

Tengo este DQL que me da error:
Código PHP:
$role $this->em->createQuery('SELECT h.role FROM Application\Entity\Histousuario h WHERE (h.id = :id)');
$role->setParameters(array(
    
':id' => $id
)); 
role, asi esta en mi entidad
Cita:
* @ORM\ManyToOne(targetEntity="Application\Entity\Ro les")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="role_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
* })
*/
private $role;
el error que me muestra es este:
Cita:
Fatal error: Uncaught exception 'Doctrine\ORM\Query\QueryException' with message 'SELECT h.role FROM Application\Entity\Histousuario h WHERE (h.id = :id)' in C:\xampp\htdocs\bcbtram\library\Doctrine\ORM\Query \QueryException.php:39
  #2 (permalink)  
Antiguo 17/05/2013, 12:39
 
Fecha de Ingreso: enero-2010
Mensajes: 491
Antigüedad: 14 años, 3 meses
Puntos: 12
Respuesta: Error en DQL

Lo resolve de esta manera:
Código PHP:
        $role $this->em->createQuery('SELECT r.id FROM Application\Entity\Histousuario h JOIN h.role r WHERE (h.id = :id)');
        
$role->setParameters(array(
                
':id' => $id
                
));
        
$role $role->getResult(); 
Existe otra forma de obtener el dato del campo que no requiera llamar a la entidad referenciada?

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 01:15.