此查询有效:
$player_id = $_POST['player_id'];//array $ids = explode(',',$player_id); $in = implode(',', array_fill(0, count($ids), '%d')); $wpdb->query($wpdb->prepare("DELETE FROM {$player_table} WHERE id IN ($in)", $ids));
这不会:
$disabled = $_POST['disabled']; $media_id = $_POST['media_id'];//array $ids = explode(',',$media_id); $in = implode(',', array_fill(0, count($ids), '%d')); $wpdb->query($wpdb->prepare("UPDATE {$media_table} SET disabled = %s WHERE id IN ($in)", $disabled, $ids));
我不明白为什么。
您需要将IDS分散为单独的参数,以匹配查询中的所有
%s
。使用...
语法来实现。