Skip to content

Query Builder set update not working correctly #2959

Description

@crustamet

Codeigniter 4.0.3 version.

$builder->set('order', 'order+1')
	->where('order >=', 0)
	->update();

produce query

UPDATE `core_cms_banners` SET `order` = 'order+1' WHERE `order` >= 0

This is good but i wanted to update with a numeric value based on order so i have this code

$builder->set('order', 'order+1', FALSE)
	->where('order >=', 0)
	->update();

produced query

UPDATE `core_cms_banners` SET order = order+1 WHERE `order` >= 0

For this i get error from db because of fields are not incapsulated correctly
So i tried this code

$builder->set('`order`', '`order`+1', FALSE)
	->where('order >=', 0)
	->update();

so i get THIS QUERY

UPDATE `core_cms_banners` SET order = `order`+1 WHERE `order` >= 0

there is missing qutoes for the first order text like it is removed from nowhere even with third parameter $escape as FALSE

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions