ResourceController inserts 0000-00-00 00:00:00 on empty string? |
I pass query data to the default update method on a ResourceController, but it inserts 0000-00-00 00:00:00 into the timestamp instead of the default NULL the database is set to use.
Now, WHY does it do that, and HOW (apart from overriding the update method, rewriting it completely – which makes the whole point of the ResourceController obsolete), can I make it accept the empty string as a NULL value? Or, to put it in another way: Why does CI 4 ResourceController default update method in a model set timestamp to: 0000-00-00 00:00:00 when the default is set to NULL and it receives an empty string?
Hmmm, try setting null to true in dbforge perhaps? Oh wait you're using CI4 my bad
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
There is no ResourceController class in CI4.
Controllers do not work with the base. Where is the problem area code? (04-05-2022, 08:42 AM)Really?iRedds Wrote: There is no ResourceController class in CI4.Check this out: https://codeigniter4.github.io/userguide...controller
I was looking for ResponseController instead of ResourceController. Ha ha I'm an idiot.
Yes, here I was wrong. Honestly, I do not understand the meaning of this controller. Someone's bad joke? The ResourceController requires methods to be implemented. Where is your code?
It is MySQL thing, not CodeIgniter, not ResourceController.
An empty string ('') is not null. If you want to insert null, convert the empty string to null in PHP. Code: create table test_datetime PHP Code: <?php Code: .../app/Controllers/Home.php:17:
Thank you Kenjis, nice explanation.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
|
Welcome Guest, Not a member yet? Register Sign In |