[web2py] Re: database query on nested tables

2014-04-08 Thread 黄祥
hi, consider this : # e.g. 1 work for row in db(db.product).select(): print row.rack.branch # e.g. 2 not work print db(db.product.rack.branch == 1).select() is it possible to have the example 2 work? thanks and best regards, stifan -- Resources: - http://web2py.com - http://web2py.com/book

[web2py] Re: database query on nested tables

2014-04-08 Thread Dave S
On Wednesday, April 10, 2013 7:31:35 AM UTC-7, Niphlod wrote: I did say see it prettydate as it is takes a date and calculates automatically the timedelta to now. You need to have your own prettydate to be able to pass a timedelta of your own. If you've got a datetime.datetime

[web2py] Re: database query on nested tables

2014-04-08 Thread Derek
John Resig wrote a 'prettydate' that is probably what he wants... http://ejohn.org/blog/javascript-pretty-date/ On Wednesday, April 10, 2013 7:31:35 AM UTC-7, Niphlod wrote: I did say see it prettydate as it is takes a date and calculates automatically the timedelta to now. You need

[web2py] Re: database query on nested tables

2014-04-08 Thread Niphlod
On Tuesday, April 8, 2014 2:44:52 PM UTC+2, 黄祥 wrote: hi, consider this : # e.g. 1 work for row in db(db.product).select(): print row.rack.branch # e.g. 2 not work print db(db.product.rack.branch == 1).select() is it possible to have the example 2 work? no, you can't.

[web2py] Re: database query on nested tables

2014-04-08 Thread 黄祥
now, i know the reason why, thank you so much for your explaination, niphlod. best regards, stifan On Wednesday, April 9, 2014 4:49:26 AM UTC+7, Niphlod wrote: On Tuesday, April 8, 2014 2:44:52 PM UTC+2, 黄祥 wrote: hi, consider this : # e.g. 1 work for row in db(db.product).select():

[web2py] Re: database query on nested tables

2013-04-10 Thread 黄祥
sorry the table for check out is db.define_table('check_out', Field('check_in', 'reference check_in'), Field('room'), Field('guest'), Field('description', 'text'), Field('duration'), format='%(guest)s %(room)s') i extract the room and guest value from check_in table and

[web2py] Re: database query on nested tables

2013-04-10 Thread Massimo Di Pierro
check_in = db.check_in[id] print check_in.room.category.price On Wednesday, 10 April 2013 04:38:08 UTC-5, 黄祥 wrote: hi folks, i want to get the value of table row that have 3 nested values. my goal is to get the price value from table room_category from function check_out in my

[web2py] Re: database query on nested tables

2013-04-10 Thread Massimo Di Pierro
PS. Anyway, I would copy the price into check_in and check_out tables. I know this is redundant but in any hotel you will have to handle discounts for each individual client (to handle complaints, friends, etc.) This will give you flexibility and make it faster. On Wednesday, 10 April 2013

[web2py] Re: database query on nested tables

2013-04-10 Thread 黄祥
brilliant, very simple solution, it's work now. thank you so much for your solution and suggestion, massimo i've followed your hints and make it on my controller : def __onvalidation_check_out(form): if form.vars.check_in: rows = db(db.check_in.id==form.vars.check_in).select()

[web2py] Re: database query on nested tables

2013-04-10 Thread Niphlod
check prettydate http://web2py.com/books/default/chapter/29/14?search=prettydate On Wednesday, April 10, 2013 3:45:19 PM UTC+2, 黄祥 wrote: brilliant, very simple solution, it's work now. thank you so much for your solution and suggestion, massimo i've followed your hints and make it on my

[web2py] Re: database query on nested tables

2013-04-10 Thread 黄祥
when i tried to using prettydate it return [invalid date] e.g. *from gluon.tools import prettydate* def __onvalidation_check_out(form): if form.vars.check_in: rows = db(db.check_in.id==form.vars.check_in).select() for row in rows: form.vars.room = row.room

[web2py] Re: database query on nested tables

2013-04-10 Thread Niphlod
I did say see it prettydate as it is takes a date and calculates automatically the timedelta to now. You need to have your own prettydate to be able to pass a timedelta of your own. -- --- You received this message because you are subscribed to the Google Groups web2py-users group.