本文整理汇总了PHP中Song::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Song::getId方法的具体用法?PHP Song::getId怎么用?PHP Song::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Song
的用法示例。
在下文中一共展示了Song::getId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addSong
/**
* Add a song to the library
*
* @param artist_id int: the related artist primary key
* @param album_id int: the related album primary key
* @param genre_id int: the related genre primary key
* @param song_array array: the array of song info
* @return int: the song insert id
* @see apps/client/lib/MediaScan.class.php for information about the song_array
*/
public function addSong($artist_id, $album_id, $last_scan_id, $song_array)
{
if (isset($song_array['filename']) && !empty($song_array['filename']) && isset($song_array['mtime']) && !empty($song_array['mtime']) && $last_scan_id) {
$song = new Song();
$song->unique_id = sha1(uniqid('', true) . mt_rand(1, 99999999));
$song->artist_id = (int) $artist_id;
$song->album_id = (int) $album_id;
$song->scan_id = (int) $last_scan_id;
$song->name = $song_array['song_name'];
$song->length = $song_array['song_length'];
$song->accurate_length = (int) $song_array['accurate_length'];
$song->filesize = (int) $song_array['filesize'];
$song->bitrate = (int) $song_array['bitrate'];
$song->yearpublished = (int) $song_array['yearpublished'];
$song->tracknumber = (int) $song_array['tracknumber'];
$song->label = $song_array['label'];
$song->mtime = (int) $song_array['mtime'];
$song->atime = (int) $song_array['atime'];
$song->filename = $song_array['filename'];
$song->save();
$id = $song->getId();
$song->free();
unset($song, $song_array);
return $id;
}
return false;
}
示例2: addslashes
# Process sign in
if (isset($_POST['signin']) && empty($_POST['signin']) && !empty($_POST['username']) && !empty($_POST['email']) && !empty($_POST['password']) && !empty($_POST['password-confirm']) && $_POST['password'] === $_POST['password-confirm']) {
$user = addslashes(htmlspecialchars($_POST['username']));
$email = addslashes(htmlspecialchars($_POST['email']));
$passwd = addslashes(htmlspecialchars($_POST['password']));
User::create($user, $email, $passwd);
$_SESSION['signedIn'] = true;
}
# Process comment
if (isset($_POST['comment']) && isset($_POST['song']) && is_numeric($_POST['song']) && isset($_POST['text']) && !empty($_POST['text']) && preg_match("/[a-zA-Z0-9]/", trim($_POST['text'])) && isset($_SESSION['online']) && $_SESSION['online']) {
$db = $_SESSION['db'];
$song = new Song($_POST['song']);
$user_id = $_SESSION['user']->getId();
$text = preg_replace("/_3/", "♥", htmlspecialchars(trim(preg_replace("/<3/", "_3", $_POST['text']))));
$stmt = $song->userHasCommented($user_id) ? $db->prepare("update comment set text = :text, date = unix_timestamp() where user = :user and song = :song;") : $db->prepare("insert into comment (user, song, text, date) values (:user, :song, :text, unix_timestamp());");
$stmt->execute(array("user" => $user_id, "song" => $song->getId(), "text" => $text));
$stmt->closeCursor();
$_SESSION['commented'] = true;
}
# Process regular search
/**
* @author Jérôme Boesch
*
*/
if (isset($_GET['q']) && !empty($_GET['q'])) {
$db = $_SESSION['db'];
$q = htmlspecialchars($_GET['q']);
$search_songs = array();
$search_albums = array();
$search_artists = array();
$search_users = array();