Thanks Stifan,
I see how can I do that for the whole query.

How can I do this row-wise? Can I create a "count_db" variable per row? As
I'm grouping by game and counting how many entries I have per game (after
grouping them), I would like to show the count per row.

The closest I got so far is by printing the whole row using:

<li>{{=r}}
{{=A(r.probdata.game,_href=URL('list_problems_by_game',args=r.probdata.game))}}</li>

And getting the result below:

   - <Row {'probdata': {'game': '338841246'}, '_extra':
   {'COUNT("probdata"."game")': 1L}}> 338841246
   <http://127.0.0.1:8000/paravolcar5/default/list_problems_by_game/338841246>
   - <Row {'probdata': {'game': '338978835'}, '_extra':
   {'COUNT("probdata"."game")': 2L}}> 338978835
   <http://127.0.0.1:8000/paravolcar5/default/list_problems_by_game/338978835>
   - <Row {'probdata': {'game': '338995915'}, '_extra':
   {'COUNT("probdata"."game")': 2L}}> 338995915
   <http://127.0.0.1:8000/paravolcar5/default/list_problems_by_game/338995915>

But I just want the  {'COUNT("probdata"."game")': 1L} part of the row.
Which for the lines above it would be something like this:


   - Game 338841246
   <http://127.0.0.1:8000/paravolcar5/default/list_problems_by_game/338841246>
    1
   - Game 338978835
   <http://127.0.0.1:8000/paravolcar5/default/list_problems_by_game/338978835>
    2
   - Game 338995915
   <http://127.0.0.1:8000/paravolcar5/default/list_problems_by_game/338995915>
    2

Thanks & regards, Jon.

On Fri, Dec 28, 2018 at 1:52 PM 黄祥 <steve.van.chris...@gmail.com> wrote:

> just assign it to variable then pass it to the view
> *e.g. (not tested)*
> *controllers/default.py*
> def index():
>     count_db = db(db.person.id > 0).count()
>     dict(count_db = count_db)
>
> *views/default/index.html*
> {{= count_db}}
>
> *ref:*
>
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#count-isempty-delete-update
>
> best regards,
> stifan
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to