+1 !!

I also have problems with count queries not respecting the alias I set
for a table in join statements


On Nov 11, 7:52 am, mintao <florian.fack...@mintao.com> wrote:
> Hi,
>
> Not sure if this or the doctrine newsgroup is the right place to post
> this question/bug.
>
> It's about the doctrine admin generator for the symfony backend.
> As described at page 157 of the Jobeet tutorial Symfony 1.3, Doctrine
> 1.2 I wanted to modify the list (of auctions).
>
> /apps/backend/auctions/config/generator.yml:
> [...]
> config:
>  [...]
>     list:
>         title: List of all auctions
>         display: [is_active, =product, ends, starts, min_price, user]
>         sort: [ends, desc]
>         object_actions:
>           _edit: ~
>         table_method: retrieveBackendAuctionList
>
> /lib/model/AuctionsTable.class.php:
> [...]
>   public function retrieveBackendAuctionList(Doctrine_Query $q)
>   {
>     $rootAlias = $q->getRootAlias();
>     $q  ->andWhere('(isnull('.$rootAlias.'.starts) OR ' . $rootAlias .
> '.starts<NOW())')
>         ->andWhere($rootAlias.'.ends>NOW()')
>     ;
>     return $q;
>   }
>
> The Error:
> SQLSTATE[42S22]: Column not found: 1054 Unknown column 'r.starts' in
> 'where clause'. Failing Query: "SELECT COUNT(*) AS `num_results` FROM
> `auctions` `a` WHERE (isnull(r.starts) OR `a`.`starts` < NOW()) AND
> `a`.`ends` > NOW()"
>
> As you can see, it's the same variable $rootAlias ... so it's replaced
> once by "r" and the other two times by "a" as table alias.
>
> Any ideas? Thanks :)
>
> Florian
--~--~---------~--~----~------------~-------~--~----~
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