Hi Grey,
Thanks for your response. Because of my poor English, I did not
describe the problem well and did not give a good example.
My initial idea is same as you, building a list of objects from
db.select and then return the list. Because of my little experience, I
always like to check whether there are other good solutions from
experienced developers.
My original question is, user have a list of possible search condition
for one attribute (OR, not AND), return the combination of search
results.
CREATE TABLE catalog (
id INT AUTO_INCREMENT,
name CHAR(8),
price FLOAT,
primary key (id)
);
The table is populated with data. The user want to know items in
catalog with the price in the list, [12.2, 13.4, 45.6, 78.9, ...],
building where clause for the list is one option; return a list of
db.select is another choice? Are there other good ones?
Thanks in advance.
On Aug 6, 1:03 pm, Greg Milby <[email protected]> wrote:
> i apologize Zak - i just re-read your question - i misread it.
>
> i 'think' you can pass out an object if you setup your select with a join,
> then build a structure like a list (my_list = []), then loop through your
> results, and append them to the list - then pass in the list object and loop
> through it in the template
>
> sorry for the confusion.
> ________________________________________________________http://www.superantispyware.com/superantispyware.html?rid=3971Remove
> All
> The Spyware - Not Just The Easy Ones!http://1-4-u.info| Don't send insanely
> long links!
> Need a Pick-Me-Up?http://quotes.feedtheguru.com
>
> On Fri, Aug 6, 2010 at 12:50 PM, Zak <[email protected]> wrote:
> > Hey all,
> > I have another newbie's question. I googled the question, but I can
> > not find clues.
>
> > An example code for a function, (Not real, just for showing 2
> > instances of db.select):
>
> > import web
> > db = web.database(dbn='mysql', db='mydata', user='dbuser', pw='')
> > results1 = db.select('mytable', where="name = $name1")
> > results2 = db.select('mytable', where="age = $age")
> > return (result1 + result2) ## wrong, return [results1, results2] is OK
>
> > Can I combine the out of db.select results1 and results2 to a instance
> > of db.select (Not by combining where clauses)? so the function can
> > return an object.
>
> > Thanks in advance.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "web.py" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected] <webpy%[email protected]>.
> > For more options, visit this group at
> >http://groups.google.com/group/webpy?hl=en.
--
You received this message because you are subscribed to the Google Groups
"web.py" 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/webpy?hl=en.