Welcome Guest, Not a member yet? Register   Sign In
Help needed with search query
#3

[eluser]Bus Pants[/eluser]
I tried that but if I enter more than one word in the search box I get no results...

This code:

Code:
$terms = str_replace(" ", ",", $search_term);

$this->db->select('engines.*, models.model as model_name, makes.make as make_name');
$this->db->from('engines');
$this->db->where("(engines.status = 1) AND `models`.`model` IN ('$terms') OR `engines`.`engine` IN ('$terms')");
$this->db->join('models', 'models.id = engines.model');
$this->db->join('makes', 'makes.id = engines.make');
$this->db->order_by('makes.make, models.model, engines.first_year', 'ASC');

Produces this, and no results, but there should be seven matches:

Code:
SELECT `engines`.*, `models`.`model` as model_name, `makes`.`make` as make_name
FROM (`engines`)
JOIN `models` ON `models`.`id` = `engines`.`model`
JOIN `makes` ON `makes`.`id` = `engines`.`make`
WHERE (engines.status = 1) AND `models`.`model` IN ('DOHC,Camry') OR `engines`.`engine` IN ('DOHC,Camry')
ORDER BY `makes`.`make`, `models`.`model`, `engines`.`first_year` ASC

Where did I go wrong?



Messages In This Thread
Help needed with search query - by El Forum - 05-02-2012, 01:41 PM
Help needed with search query - by El Forum - 05-02-2012, 02:41 PM
Help needed with search query - by El Forum - 05-02-2012, 03:43 PM
Help needed with search query - by El Forum - 05-02-2012, 04:16 PM
Help needed with search query - by El Forum - 05-02-2012, 06:02 PM
Help needed with search query - by El Forum - 05-02-2012, 06:18 PM
Help needed with search query - by El Forum - 05-02-2012, 06:24 PM
Help needed with search query - by El Forum - 05-02-2012, 06:28 PM
Help needed with search query - by El Forum - 05-02-2012, 07:16 PM
Help needed with search query - by El Forum - 05-03-2012, 10:06 AM
Help needed with search query - by El Forum - 05-03-2012, 09:57 PM
Help needed with search query - by El Forum - 05-04-2012, 09:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB