How To Set MySql SQL_MODE to ANSI from PHP

2019-07-13 08:42发布

MySQL Command:

set @session sql_mode = ANSI;

What is the corresponding PHP Command??

This Approach Does Not Seem To Work:

$conn= new mysqli("localhost", "root", "", "DB");
$conn->options(MYSQLI_INIT_COMMAND, "SET SQL_MODE = 'ANSI'"); 

标签: php mysqli
3条回答
地球回转人心会变
2楼-- · 2019-07-13 09:06

It seems that you have missed the scope variable,try this:

SET GLOBAL SQL_MODE = 'ANSI'

查看更多
在下西门庆
3楼-- · 2019-07-13 09:11

Does this work for you? (Sorry, can't test at the moment)

$conn->query("set @session sql_mode = ANSI;");
查看更多
仙女界的扛把子
4楼-- · 2019-07-13 09:17

I ended up using mysqli_init instead of new mysqli() and everything worked fine.

查看更多
登录 后发表回答