Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

This is my first project I started in CodeIgniter4, I have a field isdefault in my table and I want to set it to false if its true when I submit a true for isdefault in new record.

Its not working and also showing no error. Please help.

Ok, it was my mistake, change the code to one line make the work done.
PHP
$model->where(['isdefault'=> 1])->set(['isdefault' => 0])->update();


What I have tried:

PHP
if( $default== 1)
            {
                $model->where(['isdefault'=> 1])
->set(['isdefault' => 0])
->update();
            }
Posted
Updated 3-Nov-20 20:02pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900