gpt4 book ai didi

重复更新的 Mysql 不起作用?

转载 作者:行者123 更新时间:2023-11-29 01:49:35 24 4
gpt4 key购买 nike

movie_title 是一个独特的列。我想更新重复的列。查询中没有错误。

foreach($array['data'] as $row) {

$movie_title = $row[0];
$time_published = date("Y-m-d H:i:s",strtotime($row[2]));
$language = $row[3];
$views = $row[4];
$active = $row[6];
$type = $row[7];
$checked = $row[8];
$category = $row[9];
$rating = $row[10];
$subtitle = $row[12];
$visitor_views = $row[18];

if($visitor_views!=0) {
$view_array[] = $visitor_views;
}

$movie_title = explode("-",$movie_title);

$movie_title = trim($movie_title[0]);

$wpdb->query($wpdb->prepare("INSERT INTO movies (movie_title,time_published,language,views,visitor_views,active,type,checked,category,rating,subtitle) VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) ON DUPLICATE KEY UPDATE active=active,category=category,views=views,visitor_views=visitor_views,checked=checked,subtitle=subtitle,rating=rating,type=type,language=language",
$movie_title,$time_published,$language,$views,$visitor_views,$active,$type,$checked,$category,$rating,$subtitle));




}

这是查询的样子

INSERT INTO movies (movie_title,time_published,language,views,visitor_views,active,
type,checked,category,rating,subtitle)
VALUES
('Bodyguard','2016-12-17 06:54:26','1','2091','15',
'1','0','0','Feature Film ','3.66','Bodyguard.vtt')
ON DUPLICATE KEY UPDATE
active=active,category=category,views=views,visitor_views=visitor_views,
checked=checked,subtitle=subtitle,rating=rating,type=type,language=language

为什么没有更新任何列?

最佳答案

不确定这是否能解决问题,但也许应该是这样的:

ON DUPLICATE KEY UPDATE active = VALUES(active), category = VALUES(category)..

关于重复更新的 Mysql 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50291332/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com