php - delete...in() delete statement preprocessing and non-preprocessing result are different
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-24 11:32:31
0
1
908

When using delete from XXX where id in (XXX) for batch deletion, when using PDO preprocessing, only one record can be deleted at a time. The code is as follows:

<?php
require_once 'conn.php';
$items=$_POST['item'];
$itemsString=implode(",",$items);
$sql=$db->prepare("delete from tb_affiche where id in(?)");
$sql->bindParam(1, $itemsString);
$sql->execute();
?>

It can run normally without preprocessing and delete multiple records in batches. The code is as follows:

<?php 
require_once 'conn.php';
$items=$_POST['item'];
$itemsString=implode(",",$items);
$sql=$db->exec("delete from tb_affiche where id in($itemsString)");
?>

I don’t know what went wrong, please help me solve it

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(1)
小葫芦

Put () into bindParam and take a look

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template