Welcome Guest, Not a member yet? Register   Sign In
How do you guys handle search?
#1

[eluser]eclectic01[/eluser]
Let's say we want to search for a user in the database, the fields in the DB could be:

Name
Age Range
Address
City
Telephone
Email
Ethnic Origin

In the past I've handled this by, building a query using the LIKE operator and then for pagination because some of these fields are going to be empty, I've saved the query in the database

so the URLs for the pagination links would be

/search/query/<id>/<page number>

This would load the query out of the database, apply the limits using the page number.

Is this the right / secure way to do it or can someone suggest a better method?

Essentially I want to know

1)What's the best way to build the query (using like or maybe using SQL full text search?)
2)What's the best way to deal with pagination, is my current method secure enough?

Any advice would be very greatfully received!
#2

[eluser]pickupman[/eluser]
You'll notice that if you run a search on the boards here you will see the exact same functionality you just mentioned. Searches are held as DB id, and are returned from the database. If you are searching multiple fields like this, you will it easier to use this method. Otherwise set the search keyword(s) in a user's session, and retrieve accordingly.
Hint: the db method may allow you to cache the data easier. Then on subsequent request you could get the data from cache if still available. I like using the cache library.




Theme © iAndrew 2016 - Forum software by © MyBB