How to modify sql_mode or Strict Mode in MySQL?
There are cases where an application or website requires disabling a restriction of the sql_mode variable in MySQL. For example, disabling "ONLY_FULL_GROUP" or "STRICT_TRANS_TABLES".
Since it is not allowed to modify the sql_mode variable on shared hosting servers, you can modify the restrictions with the following PHP code examples:
Removing all restrictions from "sql_mode" in PDO connections:
Removing all restrictions from SQL_MODE can make your application more vulnerable to errors or unexpected behaviors. It is advisable to review and understand the implications of disabling certain restrictions before doing so in a production environment.
Removing only a specific restriction from "sql_mode" in PDO connections:
In the following example, we will only remove the "ONLY_FULL_GROUP_BY" restriction.
PreviousWhy can't IonCube activate on shared hosting servers?NextHow to set up forms if the mail() function is disabled?
Last updated