Ben Sinclair
Ben Sinclair

Reputation: 3986

How to test PHP in MySQL Strict

I had a client who had MySQL Strict which brought up a few errors in my MySQL code... I didn't even know there was a MySQL Strict. I've fixed up a lot of the issues but I want to run some further tests on my local server.

How do I enable MySQL Strict for testing purposes and then disable it when I no longer want it?

Upvotes: 1

Views: 836

Answers (1)

Matt
Matt

Reputation: 44078

From the docs:

You can change the SQL mode at runtime by using a SET [GLOBAL|SESSION] sql_mode='modes' statement to set the sql_mode system value. Setting the GLOBAL variable requires the SUPER privilege and affects the operation of all clients that connect from that time on. Setting the SESSION variable affects only the current client. Any client can change its own session sql_mode value at any time.

(Emphasis mine)

Example:

SET SESSION sql_mode='STRICT_ALL_TABLES';

Upvotes: 3

Related Questions