当前位置: 首页>>代码示例>>PHP>>正文


PHP Stats::migrate方法代码示例

本文整理汇总了PHP中Stats::migrate方法的典型用法代码示例。如果您正苦于以下问题:PHP Stats::migrate方法的具体用法?PHP Stats::migrate怎么用?PHP Stats::migrate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stats的用法示例。


在下文中一共展示了Stats::migrate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 /**
  * update
  * This function takes a key'd array of data and updates this object
  * as needed
  * @param array $data
  * @return int
  */
 public function update(array $data)
 {
     $year = isset($data['year']) ? $data['year'] : $this->year;
     $artist = isset($data['artist']) ? intval($data['artist']) : $this->artist_id;
     $album_artist = isset($data['album_artist']) ? intval($data['album_artist']) : $this->album_artist;
     $name = isset($data['name']) ? $data['name'] : $this->name;
     $disk = isset($data['disk']) ? $data['disk'] : $this->disk;
     $mbid = isset($data['mbid']) ? $data['mbid'] : $this->mbid;
     $mbid_group = isset($data['mbid_group']) ? $data['mbid_group'] : $this->mbid_group;
     $release_type = isset($data['release_type']) ? $data['release_type'] : $this->release_type;
     $current_id = $this->id;
     $updated = false;
     $songs = null;
     if ($artist != $this->artist_id && $artist) {
         // Update every song
         $songs = $this->get_songs();
         foreach ($songs as $song_id) {
             Song::update_artist($artist, $song_id);
         }
         $updated = true;
         Artist::gc();
     }
     if (!empty($data['album_artist_name'])) {
         // Need to create new artist according the name
         $album_artist = Artist::check($data['album_artist_name']);
     }
     $album_id = self::check($name, $year, $disk, $mbid, $mbid_group, $album_artist, $release_type);
     if ($album_id != $this->id) {
         if (!is_array($songs)) {
             $songs = $this->get_songs();
         }
         foreach ($songs as $song_id) {
             Song::update_album($album_id, $song_id);
             Song::update_year($year, $song_id);
             Song::write_id3_for_song($song_id);
         }
         $current_id = $album_id;
         $updated = true;
         Stats::migrate('album', $this->id, $album_id);
         Art::migrate('album', $this->id, $album_id);
         self::gc();
     } else {
         Album::update_year($year, $album_id);
         Album::update_mbid_group($mbid_group, $album_id);
         Album::update_release_type($release_type, $album_id);
     }
     $this->year = $year;
     $this->mbid_group = $mbid_group;
     $this->release_type = $release_type;
     $this->name = $name;
     $this->disk = $disk;
     $this->mbid = $mbid;
     $this->album_artist = $album_artist;
     if ($updated && is_array($songs)) {
         foreach ($songs as $song_id) {
             Song::update_utime($song_id);
         }
         // foreach song of album
         Stats::gc();
         Rating::gc();
         Userflag::gc();
         Useractivity::gc();
     }
     // if updated
     $override_childs = false;
     if ($data['overwrite_childs'] == 'checked') {
         $override_childs = true;
     }
     $add_to_childs = false;
     if ($data['add_to_childs'] == 'checked') {
         $add_to_childs = true;
     }
     if (isset($data['edit_tags'])) {
         $this->update_tags($data['edit_tags'], $override_childs, $add_to_childs, $current_id, true);
     }
     return $current_id;
 }
开发者ID:bl00m,项目名称:ampache,代码行数:84,代码来源:album.class.php

示例2: update

 /**
  * update
  * This takes a key'd array of data and updates the current tv show
  */
 public function update(array $data)
 {
     // Save our current ID
     $current_id = $this->id;
     $name = isset($data['name']) ? $data['name'] : $this->name;
     $year = isset($data['year']) ? $data['year'] : $this->year;
     $summary = isset($data['summary']) ? $data['summary'] : $this->summary;
     // Check if name is different than current name
     if ($this->name != $name || $this->year != $year) {
         $tvshow_id = self::check($name, $year, true);
         // If it's changed we need to update
         if ($tvshow_id != $this->id && $tvshow_id != null) {
             $seasons = $this->get_seasons();
             foreach ($seasons as $season_id) {
                 Season::update_tvshow($tvshow_id, $season_id);
             }
             $current_id = $tvshow_id;
             Stats::migrate('tvshow', $this->id, $tvshow_id);
             Art::migrate('tvshow', $this->id, $tvshow_id);
             self::gc();
         }
         // end if it changed
     }
     $trimmed = Catalog::trim_prefix(trim($name));
     $name = $trimmed['string'];
     $prefix = $trimmed['prefix'];
     $sql = 'UPDATE `tvshow` SET `name` = ?, `prefix` = ?, `year` = ?, `summary` = ? WHERE `id` = ?';
     Dba::write($sql, array($name, $prefix, $year, $summary, $current_id));
     $this->name = $name;
     $this->prefix = $prefix;
     $this->year = $year;
     $this->summary = $summary;
     $override_childs = false;
     if ($data['overwrite_childs'] == 'checked') {
         $override_childs = true;
     }
     $add_to_childs = false;
     if ($data['add_to_childs'] == 'checked') {
         $add_to_childs = true;
     }
     if (isset($data['edit_tags'])) {
         $this->update_tags($data['edit_tags'], $override_childs, $add_to_childs, $current_id, true);
     }
     return $current_id;
 }
开发者ID:bl00m,项目名称:ampache,代码行数:49,代码来源:tvshow.class.php

示例3: update

 /**
  * update
  * This takes a key'd array of data and updates the current artist
  * @param array $data
  * @return int
  */
 public function update(array $data)
 {
     // Save our current ID
     $name = isset($data['name']) ? $data['name'] : $this->name;
     $mbid = isset($data['mbid']) ? $data['mbid'] : $this->mbid;
     $summary = isset($data['summary']) ? $data['summary'] : $this->summary;
     $placeformed = isset($data['placeformed']) ? $data['placeformed'] : $this->placeformed;
     $yearformed = isset($data['yearformed']) ? $data['yearformed'] : $this->yearformed;
     $current_id = $this->id;
     // Check if name is different than current name
     if ($this->name != $name) {
         $artist_id = self::check($name, $mbid, true);
         $updated = false;
         $songs = array();
         // If it's changed we need to update
         if ($artist_id != null && $artist_id != $this->id) {
             $songs = $this->get_songs();
             foreach ($songs as $song_id) {
                 Song::update_artist($artist_id, $song_id);
             }
             $updated = true;
             $current_id = $artist_id;
             Stats::migrate('artist', $this->id, $artist_id);
             Art::migrate('artist', $this->id, $artist_id);
             self::gc();
         }
         // end if it changed
         if ($updated) {
             foreach ($songs as $song_id) {
                 Song::update_utime($song_id);
             }
             Stats::gc();
             Rating::gc();
             Userflag::gc();
             Useractivity::gc();
         }
         // if updated
     } else {
         if ($this->mbid != $mbid) {
             $sql = 'UPDATE `artist` SET `mbid` = ? WHERE `id` = ?';
             Dba::write($sql, array($mbid, $current_id));
         }
     }
     // Update artist name (if we don't want to use the MusicBrainz name)
     $trimmed = Catalog::trim_prefix(trim($name));
     $name = $trimmed['string'];
     if ($name != '' && $name != $this->name) {
         $sql = 'UPDATE `artist` SET `name` = ? WHERE `id` = ?';
         Dba::write($sql, array($name, $current_id));
     }
     $this->update_artist_info($summary, $placeformed, $yearformed, true);
     $this->name = $name;
     $this->mbid = $mbid;
     $override_childs = false;
     if ($data['overwrite_childs'] == 'checked') {
         $override_childs = true;
     }
     $add_to_childs = false;
     if ($data['add_to_childs'] == 'checked') {
         $add_to_childs = true;
     }
     if (isset($data['edit_tags'])) {
         $this->update_tags($data['edit_tags'], $override_childs, $add_to_childs, $current_id, true);
     }
     if (AmpConfig::get('label') && isset($data['edit_labels'])) {
         Label::update_label_list($data['edit_labels'], $this->id, true);
     }
     return $current_id;
 }
开发者ID:bl00m,项目名称:ampache,代码行数:75,代码来源:artist.class.php


注:本文中的Stats::migrate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。