CodeIgniter Forums
update(null,$data) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: update(null,$data) (/showthread.php?tid=79255)



update(null,$data) - whiteshadow - 05-18-2021

Hello,
just found something weird in CI4.
if my $id = null then the mysql update($id,$data) will update all the lines in the table.

Is that normal?


RE: update(null,$data) - paulbalandan - 05-18-2021

This is by design to allow one-time "global" updates, as discussed here and an attempt to change this behavior in here. Since this behavior is quite risky, you should put the necessary guards such that the primary ID you will be passing to update is not empty. By empty I mean anything considered by PHP as empty, such as null, false, or an empty string.


RE: update(null,$data) - moammad khalid - 05-19-2021

no body can help in this platform because i had a post but still waiting to reply from anyone.


RE: update(null,$data) - whiteshadow - 05-19-2021

(05-18-2021, 10:06 AM)paulbalandan Wrote: This is by design to allow one-time "global" updates, as discussed here and an attempt to change this behavior in here. Since this behavior is quite risky, you should put the necessary guards such that the primary ID you will be passing to update is not empty. By empty I mean anything considered by PHP as empty, such as null, false, or an empty string.
thank you