in the php project, you simply connect to mysql. through the medoo library Due to the need for batch update configuration operations, insert into. Was used On duplicate key update statement, which cannot pass the syntax check of pdo. The php code is as follows:
$medoo = new Medoo($dbcfg);
$sql = "INSERT INTO `t_config` (`name`,`value`) VALUES ("WEB_SITE_TITLE","11dd11"),("WEB_SITE_KEYWORD","22rr2") on duplicate key update `value` = VALUES(`value`); ";
$res = $medoo->exec($sql);
p($medoo->error());
p($res);
error after execution:
Array
(
[0] => 42S22
[1] => 1054
[2] => Unknown column "WEB_SITE_TITLE" in "field list"
)
PDOStatement Object
(
[queryString] => INSERT INTO t_config (`name`,`value`) VALUES("WEB_SITE_TITLE","11dd11"),("WEB_SITE_KEYWORD","22rr2") on duplicate key update `value`=VALUES(`value`);
)
but when a copy of the statement is run on the command line, the statement is normal.
then consult the relevant documents and find that there is a line of code in the source code in medoo:
// Make MySQL using standard quoted identifier
$commands[] = "SET SQL_MODE=ANSI_QUOTES";
when this line is deleted, it is ready to run.
originally because there are double quotation marks in the statement, syntax checking cannot pass after ANSI_QUOTES is enabled.
the problem that PS: has been perplexing for several days, originally intended to ask questions, did not want to solve in the process of asking questions, but also drunk. It"s like stepping on a medoo pit.