prepare($sql); $preparedQuery->bindValue(':user_id', $userId); $preparedQuery->bindValue(':project_id', $projectId); $preparedQuery->bindValue(':uploadtime', $uploadtime); $result = $preparedQuery->execute(); $database->query($sql); $sql = "INSERT INTO upload_logs (project_id, user_id, filepath, uploadtime) VALUES "; $insertRows = array(); foreach($fileList as $filepath) { $insertRows[] = "(" . $projectId . ", " . $userId . ", '" . $filepath . "', datetime('" . $uploadtime . "'))"; } $sql .= implode(", ", $insertRows); $database->query($sql); $data = array("message" => "upload log written with " . count($fileList) . " files"); return $data; } }