CodeIgniter Forums
query builder %LIKE% - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: query builder %LIKE% (/showthread.php?tid=74756)



query builder %LIKE% - notkapier - 11-02-2019

Hi, just tried the query builder on CI 3.1.10

$this->db->like('element_name',$var);
$query = $this->db->get('element');
return $query->result();

gives blank array even there are rows matching in the database.

it returns nothing, upon checking the get_compiled_select()
it only produces

select *

if i put an error on the table_name 
it gives the right query but of course with the wrong table that i placed

SELECT * FROM `elements` WHERE `element_name` LIKE '%home%' ESCAPE '!'

and if i run the corrected statement(removing the 's' in table name in mysql, it does have rows.

anyone?


RE: query builder %LIKE% - php_rocs - 11-03-2019

@notkapier,

What is your system configuration? PHP version? Database version? Any reason why you didn't upgrade to CI 3.1.11?

Have you tried it with adding this statement prior to your like statement: $this->db->select('*');

Have you tried Query binding (https://codeigniter.com/user_guide/database/queries.html?highlight=query#query-bindings)?