Hello,

I used the dql callback function preDqlSelect in order to
automatically fetch elements ordered. (solved one part of the problem)

But in some case it will be great to do :

$model->getLastActivatedComments();

function getLastActivatedComments() {
  $sub_query = Doctrine_Query_Part::Create()->where('activated = ?', true);
  return $this->getComments($sub_query);
}

So instead of rewrite the full query each time, you just 'add' a
'part' to the final query. Like propel does. (I know doctrine is not
propel ...)

The idea of 'Relation' is to avoid rewrite the full query, or to
'hide' how a relation is made of.

Thomas
On Tue, Sep 23, 2008 at 8:03 AM, Bernhard Schussek <[EMAIL PROTECTED]> wrote:
>
> Hi Thomas,
>
>
> Why don't you just query the comments independently of the blog article?
>
> $comments = Doctrine_Query::create()
>  ->from('Comment c')
>  ->where('c.article_id = ?', $yourArticleId)
>  ->orderBy('c.created_at DESC')
>  ->execute();
>
> If you put this code in the CommentTable you really don't have much
> code left in your action:
>
> $this->comments = CommentTable::findByArticle($article->id);
>
>
> Bernhard
>
>
>
> On Mon, Sep 22, 2008 at 5:40 PM, Thomas Rabaix <[EMAIL PROTECTED]> wrote:
>>
>> Hello,
>>
>> In propel it is possible to provide a Criteria objet when fetching
>> relations. This can be used to fetch, for instance, all blog comments
>> ordered by date.
>>
>> How can we achieve this with doctrine ?
>>
>> I quickly look to the code and maybe the
>> Doctrine_Relation::fetchRelatedFor should get a second parameter with
>> a Query Object and the Doctrine_Record::_get a third Query argument .
>>
>> --
>> Thomas Rabaix
>> Internet Consultant
>>
>> >
>>
>
> >
>



-- 
Thomas Rabaix
Internet Consultant

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