Welcome Guest, Not a member yet? Register   Sign In
Codeigniter Search by category and or question title.
#2

I think I may have it working now


PHP Code:
public function getQuestions($search NULL) {
  
$this->db->select('*');
  
$this->db->from('questions q');
  
$this->db->join('questions_category qc''qc.question_id = q.question_id''LEFT');
  
$this->db->join('categories c''c.category_id = qc.category_id''LEFT');

  
$this->db->or_like('q.title'$search'match');
  
$this->db->or_where('c.name'$search);
  
$query $this->db->get();

  if (
$query->num_rows() > 0) {
    return 
$query->result_array();
  } else {
    return 
false;
  }

There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
RE: Codeigniter Search by category and or question title. - by wolfgang1983 - 04-02-2017, 11:03 PM



Theme © iAndrew 2016 - Forum software by © MyBB