CodeIgniter Forums
CI 1.7.2 $this->db->like() issue? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: CI 1.7.2 $this->db->like() issue? (/showthread.php?tid=25583)



CI 1.7.2 $this->db->like() issue? - El Forum - 12-17-2009

[eluser]Mr. Fulop[/eluser]
Hi everyone.
I have an issue when using like from active record.
Code:
$domeniu = 'whatever';

$this->db->set('field','1');
$this->db->like('other_field', $domeniu);
$this->db->limit(1);
$this->db->update('table');
The above produces:
Code:
UPDATE `table` SET `field` = '1' LIMIT 1;

While the following query works fine and it is what I want:
Code:
$this->db->query("update table set field='1' where other_field like '%$domeniu%' limit 1");

Am I missing something?

Cheers,
Alex


CI 1.7.2 $this->db->like() issue? - El Forum - 12-17-2009

[eluser]saidai jagan[/eluser]
I think u can do by,
Code:
$domeniu = 'LIKE %whatever%';

$this->db->set('field','1');
//$this->db->like('other_field', $domeniu);
$this->db->where('other_field', $domeniu);
$this->db->limit(1);
$this->db->update('table');
i think u never use this Wink


CI 1.7.2 $this->db->like() issue? - El Forum - 12-17-2009

[eluser]Mr. Fulop[/eluser]
Smile I am using the full mysql query (as I stated in my post) but the idea is to use the active record without full queries if you really want a database independent application.
The like function as described in the user guide should work fine, but in this case I think it doesn't or I missed something.