• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
query builder %LIKE%

#1
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?
Reply

#2
@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/datab...y-bindings)?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.