foreach ($album->artists as $artist) { $parse_artist_uri = explode(":", $artist->uri); $artists[] = $parse_artist_uri[2]; $query = $database->prepare('INSERT IGNORE INTO artists (id, name) VALUES (:id, :name)'); $query->bindParam(':id', $parse_artist_uri[2], PDO::PARAM_STR); $query->bindParam(':name', $artist->name, PDO::PARAM_STR); $query->execute(); } $database->commit(); $database->beginTransaction(); $query = $database->prepare('INSERT INTO albums (id, upc, name, release_date, availability, popularity, tracks, image, artists, genres) VALUES (:id, :upc, :name, NOW(), :availability, :popularity, :tracks, :image, :artists, :genres) ON DUPLICATE KEY UPDATE popularity=:popularity'); $parse_album_uri = explode(":", $album_uri); $query->bindParam(':id', $parse_album_uri[2], PDO::PARAM_STR); $query->bindParam(':upc', $album->ids[0]->id, PDO::PARAM_STR); $query->bindParam(':name', $album->name, PDO::PARAM_STR); $availability = $album->availability->unrestricted ? 'ANY' : xe(implode(' ', $album->availability->territories)); $query->bindParam(':availability', $availability, PDO::PARAM_STR); $null = NULL; $query->bindParam(':tracks', $null, PDO::PARAM_NULL); $query->bindParam(':popularity', $album->popularity, PDO::PARAM_STR); $query->bindParam(':image', $null, PDO::PARAM_NULL); $s_artists = serialize($artists); $query->bindParam(':artists', $s_artists, PDO::PARAM_STR); $query->bindParam(':genres', $null, PDO::PARAM_NULL); $query->execute(); $database->commit(); /* // Why? $query = $database->prepare('SELECT * FROM spotify_releases WHERE album_uri = :album_uri AND available = :available'); $query->bindParam(':album_uri', $album_uri, PDO::PARAM_STR); $query->bindParam(':available', $available_date, PDO::PARAM_STR);
<!DOCTYPE html> <html lang="en"> <?php require_once CONFIG::get('ABSPATH') . '/src/views/partials/helpers.php'; global $include_css, $include_js, $errors; ?> <head> <title> <?php xe($display['page_title']); ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php echo web_add_css($include_css); ?> <?php echo web_add_js($include_js); ?> </head> <body> <?php echo $display['page_content']; ?> </body> </html>
$tracks_query->bindParam(':genres', $genres, PDO::PARAM_LOB); $tracks_query->bindParam(':id', $album->id, PDO::PARAM_STR); $tracks_query->execute(); } } $database->commit(); $album_ids = array(); $artist_ids = array(); } } $genre_query = $database->prepare("SELECT name FROM genres"); $genre_query->execute(); $select_genres = array(); while ($row = $genre_query->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_NEXT)) { $genre = $row[0]; $url_genres = xe($genre); $selected = ''; $count_genre_query = $database->prepare("SELECT COUNT(*) FROM albums WHERE ( genres LIKE :genre ) AND ( tracks > 3 AND tracks < 25 )"); // A way to check for an exact match in a serialized array $p_genre = '%"' . $genre . '"%'; $count_genre_query->bindParam(':genre', $p_genre, PDO::PARAM_STR); $count_genre_query->execute(); $genre_count = $count_genre_query->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_NEXT); $genre_count = $genre_count[0]; if ($genre_count > 0) { $select_genres[$genre] = '<option value="' . $url_genres . '"' . $selected . '>' . $genre . ' (' . $genre_count . ')</option>'; } } asort($select_genres); $cache->delete("genres"); $cache->set("genres", $select_genres, 60 * 60 * 24 * 365);