0
當使用以下查詢時,僅返回24條記錄,因爲兩個客戶有多個符合條件的寵物,但Doctrine不會返回我的Zend App中的其他記錄。原則1.2.3不選擇所有記錄
$q = Doctrine_Query::create()
->select('c.clientID,c.firstname,c.lastname,c.address1,c.address2,c.address3,t.county,p.name')
->from('PetManager_Model_Clients c')
->leftJoin('c.PetManager_Model_Pets p')
->leftJoin('c.PetManager_Model_Counties t')
->leftJoin('c.PetManager_Model_Groomappointments g')
->where('p.type=2 AND g.gapmtClient IS NULL');
下面的MySQL查詢返回26條記錄,任何人都可以告訴我如何複製它在教義
mysql> Select DISTINCT c.clientid,c.firstname,c.lastname,p.name
-> from (clients AS c left join pets as p on c.clientid =p.owner) left join groomappointments AS g on g.gapmtclient=c.clientid
-> where p.type=2 AND g.gapmtclient is null;
感謝清理這件事 – Graham 2011-06-05 18:11:14