Welcome Guest, Not a member yet? Register   Sign In
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.

Theme © iAndrew 2016 - Forum software by © MyBB