<?php require_once "config/config.inc"; $db = $_SESSION['db']; $stmt = $db->prepare("select id from song;"); $stmt->execute(); while ($s = $stmt->fetch(PDO::FETCH_NUM)) { $song = new Song($s[0]); $lyrics = Song::getLyricsFromAPI($song->getMainArtist(), $song->getTitle()); $stmt2 = $db->prepare("update song set lyrics = :lyrics where id = :id;"); $stmt2->bindParam("lyrics", $lyrics, PDO::PARAM_STR); $stmt2->bindParam("id", $s, PDO::PARAM_INT); if ($stmt2->execute()) { print 1; } else { print 0; } $stmt2->closeCursor(); } $stmt->closeCursor();
$stmt->closeCursor(); } # BELONG $title_genres = explode("%@", $_POST['genres_' . $n]); foreach ($title_genres as $genre) { $stmt = $db->prepare("select id from genre where label = ?;"); $stmt->execute(array($genre)); $genre_id = $stmt->fetch(PDO::FETCH_NUM); $stmt->closeCursor(); $genre_id = $genre_id[0]; $stmt = $db->prepare("insert into belong (song, genre) values (:song, :genre);"); $stmt->execute(array("song" => $song_id, "genre" => $genre_id)); $stmt->closeCursor(); } # LYRICS $lyrics = Song::getLyricsFromAPI($title_artists[0], $title); $stmt = $db->prepare("update song set lyrics = :lyrics where id = :id;"); $stmt->bindParam("lyrics", $lyrics, PDO::PARAM_STR); $stmt->bindParam("id", $song_id, PDO::PARAM_INT); $stmt->execute(); $stmt->closeCursor(); # ARTWORK Album::storeArtworkFromAPI($album_id); # KNOWN $stmt = $db->prepare("insert into know (user, song, owned, date) values (:user, :song, 0, unix_timestamp());"); $stmt->bindParam("user", $_SESSION['user']->getId(), PDO::PARAM_INT); $stmt->bindParam("song", $song_id, PDO::PARAM_INT); $stmt->execute(); $stmt->closeCursor(); $n++; }