私信  •  关注

maio290

maio290 最近创建的主题
maio290 最近回复了
5 年前
回复了 maio290 创建的主题 » 重复密钥更新时的php mysql insert不起作用
INSERT INTO `table` (`article_id`, `score_count`) 
VALUES (1922, '{\"1\":3,\"2\":2,\"3\":10,\"4\":2,\"5\":1}') 
ON DUPLICATE KEY 
UPDATE `score_count`= '{\"1\":3,\"2\":2,\"3\":10,\"4\":2,\"5\":1}'

因为你不想更新主键。

ON DUPLICATE KEY UPDATE 如果找到重复的键,则将指定的列更新为值。你在更新 article_id 已经是 1922 一千九百二十二 . 见官员 reference .

5 年前
回复了 maio290 创建的主题 » 使用php(mac)插入mysql表时出错

好吧,如果您阅读错误并查看构造函数,您会发现:

mysqli::__construct ([ string $host = ini_get("mysqli.default_host") [, string $username = ini_get("mysqli.default_user") [, string $passwd = ini_get("mysqli.default_pw") [, string $dbname = "" [, int $port = ini_get("mysqli.default_port") [, string $socket = ini_get("mysqli.default_socket") ]]]]]] )

您将套接字作为第5个参数发送,而端口是第5个参数。