Welcome Guest, Not a member yet? Register   Sign In
Assignment Operator := breaks the query builder
#1

I am try to create this query using the query builder

Code:
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 

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

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

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB