Mysqli Match subquery for search factor

34 Views Asked by At

I'm using phalcon php V5.2.2. I want to apply a search query for my online store which can find data by product_title, keywords and specification. Noted: keywords is array. I did my query like below but not getting expected results.

step 1:

Search Like: honda generator gasoline

Result : honda generator gasoline

step 2:

Search Like: hond generat gas

Result : No Data Found

I'm Getting result like step 1.

Expectation :

Search Like: hon motors gasole

OR

Search Like: honda motor gasoline diesel

Result should: honda motor gasoline diesel

    $data = htmlspecialchars($this->request->getPost('query'));
    if(!empty($data))
    {
        $a = explode(' ', $data);
        $b = array_map('trim', $a);
        $c = implode(',', $b);            

        $query = $this->db->query("SELECT id,pimg_front,product_title,keywords,specification FROM products WHERE MATCH(product_title,keywords,specification) AGAINST('$c' IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION);");
          if($query->numRows() > 0)
          {
            $this->view->setVar('data', $query->fetchAll());
            $this->view->pick('index/query');
         }else{$this->flashSession->warning("WARNING:: No Data Found!");return $this->response->redirect('index/index');}    
    }else{$this->flashSession->error("ERROR:: Query Error!");return $this->response->redirect('index/index');}
0

There are 0 best solutions below