Welcome Guest, Not a member yet? Register   Sign In
$this->db->like();
#1

[eluser]jfong[/eluser]
Is there any way to "loosen" up this function? If I use it as a search function and I search for instance, for "Computer Station" and it will find my record "Computer Station Number" properly, however it will not give me any records that have any variations of the phrase, i.e. "Computer." Is there a better way to search than using this function? Or is there a way to include wildcards? I am using the function without initiating the third parameter, so it is defaulted to include before and after as the third parameter.
#2

[eluser]tonanbarbarian[/eluser]
by default the like method will put wildcards % before and after the string provided. You can change this behaviour ot only before or only after

however what you are trying to do is not possible

If you search for "Computer Station" and you are expecting it to find just "Computer" then what you have to do is split your search term into a like per word
i.e.
Code:
$this->db->like('text', 'Computer');
$this->db->or_like('text', 'Station');
This will find any rows where the field `text` contains 'Computer' or 'Station'
#3

[eluser]jfong[/eluser]
Not sure if I am able to do that since I am using the like function to compare the entire value to a field from a database i.e. $this->db->like('dbsearchfield', $searchdata); Is there an easy way to get all values with only partial similarity, like returning matching values like "Comp" or "Station" ? Because even though I could split the words and run the like function, the rules are still to strict to get a partial match.




Theme © iAndrew 2016 - Forum software by © MyBB