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

[eluser]MikePearce[/eluser]
Hi all,

Is there a way to specify whether you have the percent sign and the beginning, end or both ends of the $match?

Code:
'%a match'
'%a match%'
'a match%'

Cheers,

Mike
#2

[eluser]Michael Wales[/eluser]
No, the Active Record class has the surrounding %'s hard-coded in.
Code:
$this->ar_like[] = $prefix." $k LIKE '%{$v}%'";

You could always just execute your own query:
Code:
$query = $this->db->query("SELECT * FROM table WHERE field LIKE '%" . $this->db->escape_str($match) . "'");
#3

[eluser]ELRafael[/eluser]
hahahaha... i just got the same problem!!!

well, it's fixed for me like this:

Code:
$tabela = "opt_cidades";
$this->db->where('nome LIKE', "$_cidade%");  //See?
$this->db->orderby('nome');
$this->db->limit(15);
$query = $this->db->get($tabela);

:gulp:
#4

[eluser]Michael Wales[/eluser]
good point Rafael - I didn't even think of just using the normal where() method
#5

[eluser]ELRafael[/eluser]
neither i!!!

but i gone to user guide (but there don't say nothing about this), and see the example,
Code:
$this->db->where('field !=', $var);

well, i think is a thing to tell to the users... a search like "SELECT * FROM table WHERE field LIKE some%" is very usual!! (In my case for ajax.autocompleter)

[]




Theme © iAndrew 2016 - Forum software by © MyBB