I ran headlong into this one 6 months
The only sane thing you can do is the following two steps
STEP 01
Add this to my.cnf under the [mysqld]
group header
[mysqld]
sql_mode = ''
STEP 02
Login as root@localhost
and run this
mysql> SET GLOBAL sql_mode = '';
Restarting mysql is not required.
STEP 03 (Optional)
STEP 02 only affects incoming connections after the change. You may have to kill all current DB Connections. Let the app reconnect and it will begin with sql_mode as blank. While restarting mysql is not needed for incoming connections, you could just run service mysql restart
instead of custom scripting the killing of DB Connections.
If you want to custom script the killing of your connections, please see some of my past posts for exmaples on how to kill many connections:
STEP 04 (Optional, Last Resort)
If you would like to make code changes, the only change would be to run
SET sql_mode = '';
as the first command for the connection. Then, you could run your regular queries thereafter.
GIVE IT A TRY !!!
NOTE #1 : The first two steps are more than enough for your app if you close your connection right after running your query. If your connections are persistent, then you will need STEP 03.
NOTE #2 : If you are not allowed to change the configuration, you could skip STEP 01 and STEP 02 and just run STEP 03 and STEP 04.