function _searchProductByName($name = "") {
$query = $this->db
->select("S.*,CC.id as catId, CC.name as CatName")
->from("categories as S")
->join("categories as C",'C.id=S.parentid','LEFT')
->join("categories as CC",'CC.id=C.parentid','LEFT')
->where("S.order", 2)
->like("S.name", $name, 'both')
->order_by("S.name", 'asc')
//->order_by('locate('.$name.', S.name) asc, S.name asc')
->get();
return $query && $query->num_rows() ? $query->result() : [];
}
when my keywords is lap it gives results:
{
"status": true,
"response": [
{
"id": "834",
"parentid": "46",
"name": "Collapsible Wardrobes",
"order": "2",
"hasChild": "0",
"icon": null,
"created": "2018-01-15 15:01:45",
"catId": "5",
"CatName": "Home Furniture, Decor , Pets"
},
{
"id": "936",
"parentid": "51",
"name": "Laptop Desks",
"order": "2",
"hasChild": "0",
"icon": null,
"created": "2018-01-15 15:01:45",
"catId": "5",
"CatName": "Home Furniture, Decor , Pets"
},
{
"id": "936",
"parentid": "51",
"name": "mobile latptop",
"order": "2",
"hasChild": "0",
"icon": null,
"created": "2018-01-15 15:01:45",
"catId": "5",
"CatName": "Home Furniture, Decor , Pets"
}
]
}
when i use after in place or both it gives only Laptop Desks result but i need when i search for lap it gives me result.
Laptop Desk and mobile laptops
the first data is Collapsible Wardrobes which contains lap but it is in between collapsible which i don't need how do i get this?