I am fairly new to prepared statements and am in the process of transitioning a project...
The last piece I have to transition is a piece where I have to update multiple rows/records.
This seems to work for me... However, I am curious and wondering about my technique and also sending back some sort of response (boolean or other) that everything was a success or failure. Thoughts? Comments? Suggestions?
function timeUpdate($uID, $galArr, $timeStamp) {
global $mysqli; //my connection is set elsewhere (bad/good?)
$q = "UPDATE someTable SET timeStamp = ? WHERE galleryID = ? AND uniID = ?";
$stmt = $mysqli->prepare($q);
$stmt->bind_param("iii", $timeStamp, $gID, $uID);
foreach($galArr as $value) {
$gID = $value[0];
if(!$stmt->execute()) {
throw new Exception($stmt->error, $stmt->errno);
}
}
$stmt->close();
}
Thanks in advance. Any links, suggestions are appreciate.