Hi  Valkerian,

thanks for this solution. I will try to get it working this week .


2009/4/17 Valkerian <[email protected]>

>
> Hi there, it takes a bit of doing and there's a bunch of gotchas but
> here's how I did it:
>
> In the appropriate doctrine class I did this:
>
> public function getByLastname($lastname) {
>
> $cnn = Doctrine_Manager::connection();
> $quoted_lastname = $cnn->quote($lastname, 'string');
> $people = $cnn->fetchAssoc("
> (
> select first_name, last_name, name_slug
> from director
> where last_name like $quoted_lastname
> )
> union all
> (
> select first_name, last_name, name_slug
> from actor
> where last_name like $quoted_lastname
> )
> ");
>
> return $people;
> }
>
> This will return an associative array of what you're looking for.
>
> Valk
> On Mar 25, 3:30 am, pixelmeister <[email protected]> wrote:
> > Hi @all,
> >
> > i have to solve a problem with doctrine which I normally would do with
> the
> > mysql union function.
> > Perhaps someone has an Idea for me, how I can do this:
> >
> > I have a few tables whitch have the following setup:
> >
> > ------------------------------------------
> > table name: director
> >
> > first_name: string
> > last_name: string
> > name_slug: string
> > ------------------------------------------
> >
> > table name: actor
> >
> > first_name: string
> > last_name: string
> > name_slug: string
> > ------------------------------------------
> >
> > ... and so on.
> >
> > The tables contain different persons related to movies. For example:
> > directors, screenwriters, actors, cutters and so on.
> >
> > Now, for a new function, i need to select all persons from all tables
> where
> > last name ist starting with (for Example) A%, sortetd by last_name.
> >
> > How would you do the doctrine query?
> >
> > Perhaps I have to select the perons table per table and merge them later
> in
> > arrays... and then write a sort function for the arrays? But somehow I
> dont
> > like this way ;-)
> >
> > Any suggestions would be grat. Thanks,
> >
> > Kai
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to