Very very helpfull, thank you very much!
Now It's clear :D

On 4 April 2011 17:07, Roger Webb <webb.ro...@gmail.com> wrote:

> Hello again,
>
> Here is a more concrete example:
>
> class UserTable extends Doctrine_Table {
>
>    public function findActiveUsersByUsername($username) {
>        return Doctrine_Query::create()
>                   ->from('Users u')
>                   ->where('u.username = ?', $username)
>                   ->andWhere(u.active = 1)
>                   ->execute();
>    }
>
> }
>
> $users = Doctrine_Core::getTable('User')-
> >findActiveUsersByUsername('john_smith');
>
> As you can see in the example, we use Doctrine_Query in the Table
> Class to retrieve our users in exactly the same way that we would
> without the Table Class, but leaving it inside the Table Class allows
> us to re-use this query over and over.  If you're sure that you will
> only use the query you created in one place, by all means, leave it
> outside of the Table Class, but if you think you might use it in more
> than one place, put it in a function.
>
> Roger
>
>
> On Mar 31, 8:52 pm, FHoerth <fed...@gmail.com> wrote:
> > I Just posted my answer but it seems that was an error, if tomorrow
> > doesn't appear I will answer again.
> > Thank you for answering Roger
> >
> > On 1 abr, 00:13, Roger Webb <webb.ro...@gmail.com> wrote:
> >
> > > As I best understand it, the "table" object is supposed to act as a
> > > repository.  You would, ideally, add methods to the table class to
> > > retrieve instances of 'tableClass'.
> >
> > > It may be better illustrated with an example:
> >
> > > You have a class(model) User.  In your UserTable class you might make
> > > a method called "findActiveUserByUsername()" to find all active
> > > users.
> >
> > > If you were to use Doctrine_Query::create()->from('User
> u')->where('u.active = 1');  you would get the same result, but your query
> >
> > > would not be re-usable.
> >
> > > Roger
> >
> > > On Mar 31, 1:54 pm, FHoerth <fed...@gmail.com> wrote:
> >
> > > > Hi!
> > > > Can someone explain me what is the difference between:
> >
> > > > $this->var = Doctrine_Core::getTable('tableClass')-
> >
> > > > >createQuery('alias')->where('alias.column > ?', date);
> >
> > > > and this?
> >
> > > > $this->var = Doctrine_Query::create()->from('tableClass alias')-
> >
> > > > >where('alias.column > ?', date);
> >
> > > > Why not using a single method?
> >
> >
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> 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
> symfony-users+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

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
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to