im sorry to hear that... but my next project i will start with doctrine for sure.
Thanks all On Tue, Dec 1, 2009 at 12:23 PM, Daniel Lohse <[email protected]>wrote: > This will get messy very fast. Imagine only 20 categories and for this > simple count, you'll already have 20 queries. Not good. :( > > Normally, you'd do a count on the category_id column and group by the same > category_id column. So simple in SQL/Doctrine but so hard in Propel. :( > > > Daniel > > On 2009-12-01, at 1/December, 2:58 PM, Gareth McCumskey wrote: > > First, you will always have a category with at least one product because > you have set cascade on delete. > > For the second part, in your CategoryPeer class: > > public static function getProductCountPerCategory() > { > //Get all categories > $category_obj_arr = self::doSelect(new Criteria()); > > //Get count of products per category > $product_per_category_count = array(); > > foreach ($category_obj_arr as $category_obj) > { > $product_c = new Criteria(); > $product_c->add(ProductPeer::CATEGORY_ID, $category_obj->getId()); > $product_per_category_count[$category_obj->getTitle()] = > ProductPeer::doCount($product_c); > } > > return $product_per_category_count; > } > > Thats one example. You don't always have to do everything in a query using > joins and to be honest we have often seen massive performance improvements > NOT using switching away from joins. > > On Tue, Dec 1, 2009 at 2:56 PM, g0d br <[email protected]> wrote: > >> Hi, >> >> I dont even know how to ask that but i want to show what i need. >> >> my schema.yml >> category: >> id: ~ >> title: { type: varchar(100), required: true, index: unique } >> >> product: >> id:~ >> category_id: { type: integer, foreignTable: category, foreignReference: >> id, onDelete: cascade } >> name: { type: varchar(100), required: true, index: unique } >> >> i want to retrieve all categories that have a least one product and i want >> to show how many products each category. >> >> thank you. >> >> Celso >> >> ps. sorry about my english i dont know if the question is understandable. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "symfony users" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<symfony-users%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/symfony-users?hl=en. >> > > > > -- > Gareth McCumskey > http://garethmccumskey.blogspot.com > twitter: @garethmcc > > -- > You received this message because you are subscribed to the Google Groups > "symfony users" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/symfony-users?hl=en. > > > -- > You received this message because you are subscribed to the Google Groups > "symfony users" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<symfony-users%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/symfony-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.
