Okay i'll give that a try. So I'll iterate through my list first and then
use that clause?
For id in records:
[row.id for row in db(db.search_queries == id).select(db.table.id)]
?? Put something like that into the controller as SQLFORM and it will
return those records? This is so awesome!
On Tuesday, April 29, 2014 10:04:40 AM UTC-4, Richard wrote:
>
> This should return a list of ids :
>
> [row.id for row in db(SQL WHERE CLAUSE).select(db.table.id)]
>
> Richard
>
>
> On Tue, Apr 29, 2014 at 10:02 AM, LoveWeb2py <[email protected]<javascript:>
> > wrote:
>
>> Thank you, Richard! This is great. How could I pass the parameters from a
>> list though? I'm still learning the DAL. So if I have 6 records I want to
>> return with the id in the list [1,2,5,7,204]
>>
>> How could I do that? Any code example would help.
>>
>> On Tuesday, April 29, 2014 9:58:03 AM UTC-4, Richard wrote:
>>
>>> Sure!
>>>
>>> Custom :
>>> You create a form (with SQLFORM) to get what the user want to know that
>>> gonna be the parameters of your search... Then you make a query
>>> (db(db.table.field_in_which_you_search == the_parameters_you_get_by_
>>> your_form).select(db.table.ALL), you create a grid with the results of
>>> the search...
>>>
>>> Web2py built-in with SQLFORM.grid()
>>> You can also use SQLFORM.grid() that will display a grid with a few
>>> records (inline) and there is a built-in query builder and search field...
>>> If you input your creteria in the field something like
>>> "db.table.field_you_want_to_search_in == your_creteria you" will get
>>> the records that correspond to you creteria if any.
>>>
>>> If you only want a list of ids for internal use in another function the
>>> custom way is maybe more what you want... But if you build this list just
>>> to get the record and want to display them latter you should think to use
>>> SQLFORM.grid that provide all what you want as far as I understand what you
>>> need.
>>>
>>> Richard
>>>
>>>
>>>
>>> On Tue, Apr 29, 2014 at 9:27 AM, LoveWeb2py <[email protected]> wrote:
>>>
>>>>
>>>> Hello,
>>>>
>>>> I'm trying to create a search function that allows users to search the
>>>> database without accessing the SQLFORM.
>>>>
>>>> Is there a good way to display multiple results based on the record id?
>>>> Could I create a unique SQLFORM view just on the record IDs that are
>>>> retrieved?
>>>>
>>>> Basically my search goes through and checks their search against a huge
>>>> database. If their search hits on something in the database I append the
>>>> record ID to a list.
>>>>
>>>> Records = [1,2,5,7,204]
>>>>
>>>> Is there a way for me to only show those records to them?
>>>>
>>>> --
>>>> 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 [email protected].
>>>>
>>>> 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 [email protected] <javascript:>.
>> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.