Welcome Guest, Not a member yet? Register   Sign In
MySql LIKE
#1

Hello everyone,

I am trying to do a sql query with LIKE:
PHP Code:
$this->db->query("SELECT * FROM pvp_map WHERE Server_Id = ".$Id." AND Name LIKE '%".$this->db->escape_like_str($Name)."%' ESCAPE '!' GROUP BY Player_Id, Name ORDER BY Name LIMIT ".$start.",".$limit); 

But when the string that is getting escaped starts with an ! it doesn't give any results.
This is a problem: !Joker!
This is NOT a problem: Joker!

Does anyone know how to fix this please?

I have to leave ESCAPE '!' in the query or else strings containing % or _ wont work.

The issue also happens when I do this:
PHP Code:
$this->db->where('Server_Id'$Id);
 
           $this->db->like('Name'$Name);
 
           $this->db->group_by(array("Player_Id""Name"));
 
           $this->db->order_by('Name');
 
           $this->db->from('pvp_map'); 
Reply


Messages In This Thread
MySql LIKE - by glennm - 02-15-2016, 02:32 PM
RE: MySql LIKE - by glennm - 02-17-2016, 08:27 AM
RE: MySql LIKE - by keulu - 02-17-2016, 08:34 AM
RE: MySql LIKE - by Narf - 02-17-2016, 09:19 AM
RE: MySql LIKE - by glennm - 02-17-2016, 10:59 AM
RE: MySql LIKE - by Narf - 02-17-2016, 11:27 AM
RE: MySql LIKE - by glennm - 02-17-2016, 11:39 AM
RE: MySql LIKE - by glennm - 02-17-2016, 11:53 AM
RE: MySql LIKE - by Narf - 02-17-2016, 12:12 PM
RE: MySql LIKE - by glennm - 02-17-2016, 12:22 PM
RE: MySql LIKE - by skunkbad - 02-17-2016, 03:51 PM
RE: MySql LIKE - by glennm - 02-17-2016, 05:53 PM
RE: MySql LIKE - by skunkbad - 02-17-2016, 09:00 PM
RE: MySql LIKE - by Narf - 02-18-2016, 02:48 AM
RE: MySql LIKE - by glennm - 02-18-2016, 04:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB