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

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.
$model->where(['isdefault'=> 1])->set(['isdefault' => 0])->update();

What I have tried:

if( $default== 1)
                $model->where(['isdefault'=> 1])
->set(['isdefault' => 0])
Updated 3-Nov-20 20:02pm

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