function deletePhoto($albumName, $path, $email, $ip) { if (removePhoto($nick, $path, $albumName)) { addAction($nick, $email, $ip, 'delete_photo'); return true; } return false; }
function removeOldestPhoto($toilet_id) { $db = connect(); $result = null; $maxcount = 5; $sql = 'SELECT id, toilet_id, filename FROM photos WHERE toilet_id = :toilet_id ORDER BY postdate DESC LIMIT ' . $maxcount . ',100'; try { $stmt = $db->prepare($sql); $stmt->bindParam(':toilet_id', $toilet_id); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($result as $photo) { removePhoto($photo); } } catch (PDOException $e) { echo $e->getMessage(); } }