Hi Mohammad,
I found this symfony code snippet that helped me do what you are
asking:
http://trac.symfony-project.com/wiki/ApplyingCustomJoinsInDoSelect

As a bit of a side, my Many2Many relation involved data that I wanted
to essentially group into one column. That is, say a table of books, a
table of names, and a bridge table of authors. My final output would
ideally have: "Book Title", "Author 1, Author 2, Author 3" etc. Or,
"Name", "Book 1, Book 2, Book 3" etc  (all depending on which way I
wanted to go through the data.

In that instance I did a bit of a hack into the criteria to get the
concatenated column of names:
                $criteria->addAsColumn('custmoized_names_column',
'GROUP_CONCAT(DISTINCT  name_table.NAME ASC SEPARATOR ", ")' );

You also need to add a GROUP BY column via:
                $criteria->addGroupByColumn(BookTablePeer::BOOK_ID);


Lastly, you would need to update the "startcolumn" (based upon what is
in the link I pasted above). That is, the final column would be the
concatenated string of names, and if you add any columns after that,
your next column would have to add a "+1" to the startcolumn (again,
see the link above for more on the "startcolumn" or "startcol"). This
is "+1" because the new column is one extra. You would also have to
create the methods in whatever object to be able to set / get this new
custom column.

I hope this helps!! :)
-Ernie
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to