This SQL用于更新大约334行。但是,当PHP
执行以下相同的SQL时:
$updateCollectsProductsQuery = $wpdb->prepare($preparedStatement, $queryParameters);
$wpdb->query($updateCollectsProductsQuery);
仅50
行被更新。有人知道为什么会这样吗?我不知道执行更新的PHP或Wordpress的限制吗?
更新1
$preparedStatement
看起来像this,而$queryParameters
看起来像this,而$updateCollectsProductsQuery
是first link。
更新2
PHP
仅更新50
中定义的前IN (prdouct_ids)
个产品ID,而wp_wps_collects
中的其余行将被删除。简而言之,此查询334
以前的SELECT * FROM wp_wps_collects WHERE collection_id = 99380101233
行现在只有50
行。这是PHP
的一些非常奇怪的行为。我只是在更新。
更新3
我将查询减少到仅51个可能要更新的行,而查询仍然仅更新50行,然后删除表wp_wps_collects
中的其他284行。这是仅传递给$wpdb->query
51
行进行更新的wp_wps_collects
时查询的样子:
UPDATE wp_wps_collects
SET
position = (CASE
WHEN product_id = 2214936019057 THEN 0
WHEN product_id = 2214936084593 THEN 1
WHEN product_id = 2214936150129 THEN 2
WHEN product_id = 2214936215665 THEN 3
WHEN product_id = 2214936281201 THEN 4
WHEN product_id = 2214936379505 THEN 5
WHEN product_id = 2214936445041 THEN 6
WHEN product_id = 2214936477809 THEN 7
WHEN product_id = 2214936510577 THEN 8
WHEN product_id = 2214936576113 THEN 9
WHEN product_id = 2214937002097 THEN 10
WHEN product_id = 2214937231473 THEN 11
WHEN product_id = 2214937722993 THEN 12
WHEN product_id = 2214937788529 THEN 13
WHEN product_id = 2214937985137 THEN 14
WHEN product_id = 2214938017905 THEN 15
WHEN product_id = 2214938116209 THEN 16
WHEN product_id = 2214938181745 THEN 17
WHEN product_id = 2214938312817 THEN 18
WHEN product_id = 2214938345585 THEN 19
WHEN product_id = 2214938574961 THEN 20
WHEN product_id = 2214938706033 THEN 21
WHEN product_id = 2214938804337 THEN 22
WHEN product_id = 2214938935409 THEN 23
WHEN product_id = 2214939000945 THEN 24
WHEN product_id = 2214939033713 THEN 25
WHEN product_id = 2214939197553 THEN 26
WHEN product_id = 2214939230321 THEN 27
WHEN product_id = 2214939263089 THEN 28
WHEN product_id = 2214939295857 THEN 29
WHEN product_id = 2214939328625 THEN 30
WHEN product_id = 2214939394161 THEN 31
WHEN product_id = 2214939426929 THEN 32
WHEN product_id = 2214939525233 THEN 33
WHEN product_id = 2214939590769 THEN 34
WHEN product_id = 2214939656305 THEN 35
WHEN product_id = 2214939754609 THEN 36
WHEN product_id = 2214939852913 THEN 37
WHEN product_id = 2214940049521 THEN 38
WHEN product_id = 2214940672113 THEN 39
WHEN product_id = 2214940934257 THEN 40
WHEN product_id = 2214941294705 THEN 41
WHEN product_id = 2214942572657 THEN 42
WHEN product_id = 2214942605425 THEN 43
WHEN product_id = 2214942638193 THEN 44
WHEN product_id = 2214942670961 THEN 45
WHEN product_id = 2214942736497 THEN 46
WHEN product_id = 2214943129713 THEN 47
WHEN product_id = 2214943457393 THEN 48
WHEN product_id = 2214943981681 THEN 49
WHEN product_id = 2214944079985 THEN 50
END)
WHERE
collection_id = 99380101233
AND product_id IN (2214936019057 , 2214936084593,
2214936150129,
2214936215665,
2214936281201,
2214936379505,
2214936445041,
2214936477809,
2214936510577,
2214936576113,
2214937002097,
2214937231473,
2214937722993,
2214937788529,
2214937985137,
2214938017905,
2214938116209,
2214938181745,
2214938312817,
2214938345585,
2214938574961,
2214938706033,
2214938804337,
2214938935409,
2214939000945,
2214939033713,
2214939197553,
2214939230321,
2214939263089,
2214939295857,
2214939328625,
2214939394161,
2214939426929,
2214939525233,
2214939590769,
2214939656305,
2214939754609,
2214939852913,
2214940049521,
2214940672113,
2214940934257,
2214941294705,
2214942572657,
2214942605425,
2214942638193,
2214942670961,
2214942736497,
2214943129713,
2214943457393,
2214943981681,
2214944079985) LIMIT 500;