2012-12-04 73 views
-3

我有一個mysql查詢,但我不知道如何在symfony2.0中進行查詢。如何在symfony2.0中編寫mysql查詢?

查詢:

SELECT a.id, a.name, 
FROM `ms_musiccategory` a 
LEFT OUTER JOIN `ms_musiccategory` b ON a.parent_Id = b.id 
ORDER BY coalesce(b.name, a.name) , a.name 
+0

@tombom:請回復不編輯... – webdeveloper

回答

-2

可能是你這樣寫:

$con = $this -> getEntityManager() -> getConnection(); 

$st = $con -> prepare(' SELECT a.* FROM `tablename` a LEFT OUTER JOIN `tablename` b ON a.parent_Id = b.id ORDER BY coalesce(b.name, a.name) , a.name'); 

$st -> execute(); 

$list = $st -> fetchAll(); 

我希望這有助於你.....

+0

感謝您的幫助.. B) – webdeveloper

+0

@tombom:如何取消它... – vipin