本文整理汇总了PHP中Song::getLyricsFromAPI方法的典型用法代码示例。如果您正苦于以下问题:PHP Song::getLyricsFromAPI方法的具体用法?PHP Song::getLyricsFromAPI怎么用?PHP Song::getLyricsFromAPI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Song
的用法示例。
在下文中一共展示了Song::getLyricsFromAPI方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: while
<?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();
示例2: explode
$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++;
}