How are you?
I am developing a program with symfony 3.4, xampp and mariadb 10. I must make a query with a nested subquery: I must go through an APPLICATION table looking for if there is not a certain PERSON that I am looking for with your ID with an existing application. I have solved it using the following code:
$subconsulta = 'SELECT p.id FROM ComensalesBundle:Persona p where p.dni = ' . $Dni ;
$consulta = 'SELECT s FROM ComensalesBundle:Solicitud s where s.persona = (' .$subconsulta. ')';
I can not get it to work using the Doctrine QueryBuilder, I use the following code:
$db = $this->getDoctrine()->getEntityManager();
$qb = $db->createQueryBuilder();
$subqb = $qb;
//escribo la subconsulta
$subqb = $subqb->select('p.id')
->from('ComensalesBundle:Persona','p')
->where('p.dni = ' . $Dni)
->getDQL()
;
//$resultado = $subqb->getResult();
//var_dump($subqb);
//escribo la consuta
$q = $qb->select('s')
->from('ComensalesBundle:Solicitud','s')
->where('s.persona = ' . $subqb)
->getQuery()
;
$resultado = $q->getResult();
I get the following error: [Syntax Error] line 0, col 89: Error: Expected Literal, got 'SELECT' I guess I'm putting the query wrong but after searching forums I can not give a solution. I am a user with little experience and I am in everything progressing in what is web programming, any contribution will be welcome. Thank you Greetings