Go to Google Groups Home    doctrine-user
Re: Help me write subquery in update query

mich <michaile...@gmail.com>

Anyone? What am I doing wrong?

On 3 июл, 22:58, mich <michaile...@gmail.com> wrote:

> I want to execute such sql:

> update blog_entry set comment_number = (select count(*) from
> blog_comment where blog_comment.root = blog_entry.id)

> How I can write such query in DQL? I tried:

>         $q = Doctrine_Query::create()
>             ->update('Blog_Entry Entry')
>             ->set('Entry.comment_number', '(SELECT COUNT(Comment.id)
> FROM Entry.Blog_Comment Comment WHERE Comment.root = Entry.id)')
>             ->execute()
>         ;

> but it throws exception "Unknown component alias Comment".