Saturday, 15 August 2015

php - Search multiple keywords in Opencart module -



php - Search multiple keywords in Opencart module -

i intend utilize search multiple keywords. made ​​a module named "residev". module find appropriate info lot of keywords entered. have if using 1 keyword, many keywords having errors.

the focus code below, changed code opencart arrangement in taking such database so. it's lot of code search keywords.

$noresinya = mysql_real_escape_string($this->request->get['nomor_resi']); $hasil = mysql_query("select * oc_order nomor_resi '%".$noresinya."%'"); $pisah_kata = explode(",", $noresinya); $produk = mysql_query("select * oc_order_product order_id = ".$hasil['order_id'].""); foreach($pisah_kata $p){ $hasil .= " or nomor_resi '%$p%' "; } while($hasilnya = mysql_fetch_array($hasil)){ // , other codes

below finish code of controller 'residev'

http://pastebin.com/uxvm6fte

below finish code of model 'residev'

http://pastebin.com/fmaymqhw

in view, form searching. can find sollution?

you have follow mvc-l (model view controller - language) code structure. so, follow rule.. model class, utilize in instead of or parts , explode logics. query should that:

where categories in ("red", "blue", "green")

and can escape method in model class pretty , easy:

$this->db->escape('$this->request->get['nomor_resi']')

and seek utilize single query. can utilize join's.

php oop opencart

No comments:

Post a Comment