Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Symfony] DOCTRINE, PROSZĘ O POMOC
blackroger
post
Post #1





Grupa: Zarejestrowani
Postów: 176
Pomógł: 0
Dołączył: 8.11.2008

Ostrzeżenie: (0%)
-----


takie zapytanie
:

  1. $recordsObjs = Doctrine_Query::create()
  2. ->select('mrg.id as id, mrg.name as name')
  3. ->addSelect('(select count(*) from mailing_email where mailing_recipent_group = id and deleted <> 1) as count_emails')
  4. ->addSelect('(select count(*) from inter_mailing_group where mailing_recipent_group = id) as count_shipping')
  5. ->from('MailingRecipentGroup mrg')
  6. ->where('mrg.tomcrm_client = ?', $tomCRMClientId)
  7. ->addWhere('mrg.deleted <> ?', 1);
  8.  


JAK SIĘ PORUSZAĆ po podzapytaniach?(IMG:style_emoticons/default/questionmark.gif) ?

dokładnie tu:

  1. ->addSelect('(select count(*) from mailing_email where mailing_recipent_group = id and deleted <> 1) as count_emails')
  2.  


chodzi o ten człon "and deleted <> 1". Chcę się odnosić do mailing_email.deleted samego podzapytania(chce traktować to jako wewnetrzne osobne podzapytania), ale niestety DOCTRINE bierze sobie samo zadeklarowany Model i traktuje to jako MailingRecipentGroup.deleted (bo też posiada takie pole...). Jak to ominąć?

Proszę aby ktoś raz na zawsze mi objaśnił jak poruszac się w podzapytaniach w Doctrine, bo ostatnimi czasy przy bardziej zaawansowanych zapytaniach psychicznie nie wyrabiam (IMG:style_emoticons/default/smile.gif) Szukałem w dokumentacji ale niestety żaden zastosowany tam przykład nie pomaga...


Wracając do pytania z innej strony....już kiedyś raz zadawałem to pytanie ale nikt nie udzielił odpowiedzi....
Na stronie Doctrine jest taki przykład....

  1. $q = Doctrine_Query::create()
  2. ->select('u.id')
  3. ->addSelect('(SELECT p.phonenumber FROM Phonenumber p WHERE p.user_id = u.id LIMIT 1) as phonenumber')
  4. ->from('User u');


poprzez analogię próbuje:

  1.  
  2. $recordsObjs = Doctrine_Query::create()
  3. ->select('mrg.id as id, mrg.name as name')
  4. ->addSelect('(select count(*) from MailingEmail me where me.mailing_recipent_group = mrg.id and me.deleted <> 1 limit 1) as count_emails')
  5. ->from('MailingRecipentGroup mrg')
  6. ->addWhere('mrg.deleted <> ?', 1);


i ciągle błąd....o co chodzi...wtf?

Ten post edytował blackroger 19.02.2011, 00:30:19
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 25.12.2025 - 13:05