from the documentation:
update_record should not be confused with
>>> row.update(name='Curt')
because for a single row, the method update updates the row object but not 
the database record, as in the case of update_record

so you should use update_record instead. or even better:
db(db.contest.id == id ).update(running = value)

which only results in one sql statement.

Alex

Am Dienstag, 2. Juli 2013 00:23:16 UTC+2 schrieb Ahmad Faiyaz:
>
> Hello, 
> i am trying to update a row on a db table, but it is not updating, what is 
> the problem ?
>
> my db table definition:
> db.define_table('contest', Field('name', length=128 ), 
> Field('contest_host', length=128,), Field('duration', 'time' ), 
> Field('time_passed','time', default = 0), Field('rank_frozen','time', 
> default = 0), Field('running',length= 10, readable=False, default = "no"), 
> Field('lang'))
>
> My update function:
>
> def flip_contest_status():
>     id = request.post_vars.id
>     row = db(db.contest.id == id ).select().first()
>     value = "no"
>     con =  row.running
>     if con is "no":
>         value = "yes"
>     db(db.contest.id == id ).select().first().update(running = value)
>     session.flash = row.name + " mode changed to "+ value
>     return locals()
>
> it doesn't update my db row !! 
>
> What to do ?
>
>

-- 

--- 
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/groups/opt_out.


Reply via email to