• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Assignment Operator := breaks the query builder

I am try to create this query using the query builder

SELECT *, (@no:[email protected]+1) AS no FROM user WHERE user.deleted = 0
 but by using the Codeigniter 4 query builder but it returns the query as 

SELECT *, (@no:[email protected]+1) AS no FROM `user` WHERE `user`.`deleted` = :user.deleted:

This is the code I used to this
$this->builder = $this->db->table('user');
$this->builder->select('*, (@no:[email protected]+1) AS no');
$this->builder->where("user.deleted", 0);

Try adding the optional FALSE parameter to the select method documented here: https://codeigniter.com/user_guide/datab...cting-data.

PHP Code:
$this->builder->select('*, (@no:[email protected]+1) AS no'FALSE); 

This prevents CodeIgniter from automatically escaping fields that may break your query.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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