0
我想通過循環綁定n個查詢並在單個調用中執行查詢。這可能嗎?如何在準備好的語句中處理多個查詢?
foreach($values as $value){
$stmt = $conn->prepare("insert into tablename (val) values (?)");
$stmt->bind_param("i",$val);
}
$stmt->execute();
我想通過循環綁定n個查詢並在單個調用中執行查詢。這可能嗎?如何在準備好的語句中處理多個查詢?
foreach($values as $value){
$stmt = $conn->prepare("insert into tablename (val) values (?)");
$stmt->bind_param("i",$val);
}
$stmt->execute();
示例代碼
$valArray = array();
foreach($values as $val)
{
$valArray[] = "($val)";
}
$valString = implode(',', $valArray);
$stmt = $pdo->query("insert into tablename (val) values $valString");