Data passed to mySQL

I recently updated my test environment to PHP 7 and mySQL 5.7 (for testing prior to my live site getting upgraded)

One thing I have noticed is that I now get an error on database calls where a numeric field is empty or a date is set to ‘0000-00-00’.

Is mySQL now applying stricter typing rules to values being passed to it? I can’t find anything about it in the online manual.

Are you using the strict type, etc?

  declare(strict_types=1); // PHP 7 specific
  error_reporting(-1); 
  ini_set('display_errors','1'); 

Can you supply the problematic script that produces these errors or are they warnings?

Edit:
I used to pass the second ini_set() variable as a boolean and had to change all occurrences to a string to prevent errors :frowning:

1 Like

@John_Betong It has nothing to do with PHP, it’s Mysql’s strict mode.

@felgall Looks like Mysql at last started setting Srict Mode in the default configuration, just like Maria DB is doing already.

If you want to revert it to the default behavior, you may set sql_mode in mysql server’s my.cnf to an empty string (or list there the settings you find appropriate).

[mysqld] 
sql_mode = ''
3 Likes

Thanks. I think I’ll leave it the way it is - there shouldn’t be many instances where I slipped up and didn’t set the correct type in the first place so there shouldn’t be too many errors and it will mean that I’ll get all the code fixed properly before the live server gets upgraded to the same.

2 Likes

@colshrapnel s of which sql version, this strict mode became default?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.