Welcome Guest, Not a member yet? Register   Sign In
Simple search engine queries
#1

[eluser]Berik[/eluser]
Hi folks!

For an upcoming project I'll be making a small and simple text-based search engine to find products on the website I'll be building.

I'm wondering what would be the best way of dealing with multiple search terms within my db query.
- Should I run a separate query for each term (and slap all the results in an array)?
- Is there a more elegant (and less ressource-hungry) way of doing it in a single query?

For a single term a simple $this->db->like('title', $term); is fine but for multiple words I was thinking of doing something along the way of:

Code:
$terms = explode(' ', $search_terms);
foreach ($terms as $term)
{
   // run a $this->db->like('db_field_to_search', $term) query
   // append results to a $search_results[] array
}

As a side question, is there a way of clearing Active Record's query parameters between each new query? Haven't found that in CI's documentation (or maybe I can't read :p)


Thanks for any input you have on the subject Smile


Messages In This Thread
Simple search engine queries - by El Forum - 12-18-2009, 07:40 AM
Simple search engine queries - by El Forum - 12-18-2009, 07:54 AM
Simple search engine queries - by El Forum - 12-18-2009, 08:28 AM
Simple search engine queries - by El Forum - 12-18-2009, 08:37 AM
Simple search engine queries - by El Forum - 12-18-2009, 08:59 AM
Simple search engine queries - by El Forum - 12-18-2009, 09:04 AM
Simple search engine queries - by El Forum - 12-18-2009, 09:33 AM
Simple search engine queries - by El Forum - 01-22-2010, 12:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB