doctrine2 - DQL Perform a union in query -


i know there several post relatives question still can't mine !

i have 2 tables (studios , models). want perform union datatable.

currently, have :

$cnn = $this->doctrine->getconnection();        $inscr = $cnn->fetchall("(select s.thedate mydate, s.name designation, \'studio\' mytype              studios s order mydate limit 2)                 union             (select m.thedate mydate, m.nickname designation, \'hotesse\' mytype               models m order mydate limit 2             )");       return $inscr; 

but nothing appears in datatable , can't perform var_dump or other.

i test in rdbms , waited results. so, ?

i found solution perform query , result

  $sql = "(select s.thedate mydate, s.name designation, 'studio' mytype  studios s order mydate limit 2)     union (select m.thedate mydate, m.nickname designation, 'hotesse' mytype   models m order mydate limit 2 )";       $stmt = $this->em->getconnection()->prepare($sql);     $stmt->execute();     return $stmt->fetchall(); 

but, unfortunatly in datatable result must instance of doctrine\orm\querybuilder , solution returns array..

if has idea special case, i'm here !


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -