I'm updating several php files which contain vulnerable mysql queries. My task of course, to incorporate prepared statements and parameter binding. I'm having trouble finding the best way to convert the following type of query to a prepared statement however.
'UPDATE `client_media` SET folder ="' . $folder_name . '" WHERE id IN ('.$media_ids.') LIMIT ' . $assetCount;
This would be so much easier if it was only the array to be bound, but i'm having a tough time because of the limit condition which comes after the array, and causes an issue when applied after the unpacked parameter.
$stmt = $db->prepare($sql);
$types = 's' . str_repeat('i', count($media_ids)) . 'i';
$stmt->bind_param($types, $folder, ...$media_ids, $assetCount);
$stmt->execute();
Any hints or ideas?
Edit: @Progman Thanks but that question assumes that the only parameter is the array. I'm talking about preparing multiple parameters one (or many) before and after the array.