2009年9月1日星期二

Re: [fw-db] Zend_Db_Table along with a COUNT() expression on a child table.

Am Dienstag, den 01.09.2009, 15:02 +0200 schrieb Christian Aarø
Rasmussen:

> So far, I seem to have made the first part work. It's the COUNT() I
> can't really get to work and I'm hoping that some of your guys and
> girls may be of some assistance.
>
> So far, the code I'm trying out with, looks like this:
>
> $select= $this->select(Zend_Db_Table::SELECT_WITH_FROM_PART);
> $select ->setIntegrityCheck(false)
>
> ->where('category_id = ?', $categoryId)
>
> ->join('users_information', 'users_information.id =
> todo_entries.id', array('user_id'=> 'id', 'name', 'username'))
>
> ->join('todo_comments', 'todo_comments.id =
> todo_entries.id', array('num_comments'=> 'COUNT(*)'));

Try (COUNT(*)) instead of COUNT(*). Means, include the parenthesis.
If this doesn't work, try it with a Zend_Db_Expr.
http://framework.zend.com/manual/en/zend.db.select.html#zend.db.select.building.columns-expr

Greetings
Andreas
--
Kraftl EDV - Dienstleistungen
Linux, Linuxschulungen, Webprogrammierung
Autofabrikstraße 16/6
1230 Wien

没有评论: