last_id =db.table.insert(item="some item") this method is the best for you then (all cred to Vidul). Just change last_id to comment and then pass comment to the view and write down the variables that you need. :)
Also, this is draginx from IRC, ask your questions there man I'll help you out again. ;) And thanks Massimo. :) On Mar 29, 7:45 pm, Michael <[email protected]> wrote: > I don't get this? > > I am just trying to display the item added last to a table. > > For instance, i have a table of quotes. > > I would like to pass variables from that table, and the LAST record to > my view. > > such as, > > return dict(author=author, quote=quote) > > But author, and quote should be from the last record added. > > On Mar 29, 7:33 pm, Vidul Petrov <[email protected]> wrote: > > > If you don't need a list, but just the last record, use the return > > value from insert: > > > last_id =db.table.insert(item="some item") > > > On Mar 30, 2:00 am, TheDude <[email protected]> wrote: > > > > Wouldn't last = db().select(db.table.ALL, orderby=~db.table.id, limit= > > > (1,))[0] be better? Since this way only one row is being retrieved and > > > less overhead? > > > > On Mar 29, 5:26 pm, mdipierro <[email protected]> wrote: > > > > > last = db().select(db.table.ALL).as_list()[-1] > > > > > On Mar 29, 3:42 pm, Michael <[email protected]> wrote: > > > > > > I wasn't sure if when you do > > > > > > query = db().select(db.table.ALL) > > > > > > returns as an array of items? > > > > > > I am trying to get the last item added into the TABLE. I thought i > > > > > could do: > > > > > > query = db().select(db.table.ALL) > > > > > last = query[-1] > > > > > return dict(last=last) > > > > > > but I am getting the following error: > > > > > > Traceback (most recent call last): > > > > > File "gluon/restricted.py", line 98, in restricted > > > > > File "/Users/michaelnovia/Documents/web2py/web2py.app/Contents/ > > > > > Resources/applications/philosaraptor/controllers/default.py", line 24, > > > > > in <module> > > > > > File "gluon/globals.py", line 75, in <lambda> > > > > > File "/Users/michaelnovia/Documents/web2py/web2py.app/Contents/ > > > > > Resources/applications/philosaraptor/controllers/default.py", line 9, > > > > > in quote > > > > > File "gluon/sql.py", line 2036, in __getitem__ > > > > > SyntaxError: SQLRows: no such row --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

