Skip to content
Advertisement

How to change sql_mode at runtime

My MySQL server’s sql_mode setting is set to STRICT. I want to change it to TRADITIONAL for a particular application I’m developing. However it’s not possible for me to do this at the server level.

Is it possible to change the sql_mode setting at runtime from my PHP scripts?

Advertisement

Answer

Hmm this should work

// connect to mysql and call the first query
mysqli_query($conn, "SET SESSION sql_mode = 'TRADITIONAL'");
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement