0

I'm working on a system with several subscribers (user_id) having multiple customers and vendors (inheriting the 'Person' class). I need to display the number of customers & vendors (group totals for the child tables) for each subscriber. How can I get a these group totals using DQL?

Person:
  columns:
    user_id: { type: integer }
    name:    { type: string(80) }
    //...

Customer:
  inheritance:
    type:     concrete
    extends:  Person
  columns:
    //...

Vendor:
  inheritance:
    type:     concrete
    extends:  Person
  columns:
    vendor_type:    { type: string(80), notnull: true }
    terms_id:       { type: integer }
    //...
qais
  • 1,808
  • 3
  • 20
  • 31

1 Answers1

0

Looking at my own question, I realized how silly it was. The query is very simple:

    $result =  Doctrine_Query::create()
        ->select('type, COUNT(*) AS count')
        ->from('Person')
        ->groupBy('type')
        ->fetchArray();
qais
  • 1,808
  • 3
  • 20
  • 31