Get KoolPHP UI with 30% OFF!

Get KoolGrid to accept NULL date?

Paul William
Hi,
My client needs some date fields to be optionally NULL, but KoolGrid seems to fail to update a date field if it doesn't have a valid date.
Any way round this?
Thanks.
Posted Feb 3, 2019 Kool
Anthony Amolochitis
I am thinking you may need to update your table in mysql.
Try setting these options in your mysql database, assuming that is what you are using.
=========================================================================
1. Make sure the following is removed from the my.ini file for mysql for "sql_mode" property.
NO_ZERO_DATE , NO_ZERO_IN_DATE
2. Make people pick a date instead of typing one into a field. Do not allow typing a date either to prevent user input error.
=========================================================================
Posted Feb 6, 2019 Kool
Anthony Amolochitis
Here is a topic in stack overflow for the NULL date values in mysql as well.
Maybe this will help you in correcting the update statement.
https://stackoverflow.com/questions/1691117/how-to-store-null-values-in-datetime-fields-in-mysql
If it helps, let me know. I'm curious.
Posted Feb 6, 2019 Kool
Paul William
I'll check that out, thanks.
This works with the CRUD front end which I'm migrating away from, which is why I think that I need to tweak something in KoolGrid.
At the moment I get "silent fails" when there's e.g. an update problem because a text field didn't have the enclosing single quotes - MySQL never gets the UPDATE command, so I assume that KoolGrod JS doesn't issue it.
Is there a way to get at the error checking to get some sort of debug info?
Posted Feb 6, 2019 Kool
Paul William
Hi,
The issue is that I can't force users to choose dates for some fields, as some dates will be unknown (maybe for years) and so must be able to be left blank.
This worked with the PHP CRUD framework I'm currently using, so I don't think that it's my MySQL settings.
Posted Feb 6, 2019 Kool
Anthony Amolochitis
I just use xdebug in netbeans 8.2 to step through the code in debug mode.
I have a windows 10 pc with WAMP installed.
I haven't ever had an issue will KoolPHP doing an update.
It's usually my query being written incorrectly when I have an issue with update.
You could write your query to a text file with file_put_contents() in php.
Also, make sure you are including KoolAjax into the page correctly too since the Koolgrid uses it's Javascript library.
If you use the event handler object for KoolGrid to manage your updates, you can get a 100% control over your update process.
Ever since I started using the event handler, I just can't go back because it works so good, and it's easy.
You get your entire row data before the update, and the new row posted data. It's pretty awesome!
Posted Feb 6, 2019 Kool
Paul William
That's the only way to go I agree, just a matter of getting round that bend in the learning curve :-)
Posted Feb 6, 2019 Kool
Anthony Amolochitis
This should help you. I added this to the code samples forum.
https://www.koolphp.net/forum/threads/82.1/koolgrid-with-an-event-handler-class--basic-crud-ops-included-in-the-class.html
Posted Feb 6, 2019 Kool