Album.php 833 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. class Album extends DBObjectAutoCreate {
  3. public $Images=array();
  4. public static function GetAlbums() {
  5. self::CreateTable("albums");
  6. $albums=array();
  7. $albumIds=self::$PDO->query("SELECT album_id FROM albums WHERE album_deleted=0");
  8. while ($albumId=$albumIds->fetchColumn())
  9. $albums[]=new Album($albumId);
  10. return $albums;
  11. }
  12. public function __construct($id=0,$forceUrl=false) {
  13. $field="album_id";
  14. if ($forceUrl || !is_numeric($id))
  15. $field="album_url";
  16. parent::__construct("albums", $field, $id);
  17. $this->Images=Image::GetImagesByAlbum($this->AlbumId);
  18. }
  19. public function Save() {
  20. if (!isset($this->AlbumUrl) || $this->AlbumUrl==null || $this->AlbumUrl=="")
  21. $this->AlbumUrl=Helper::MakeUniqueURL("albums", "album_url", $this->AlbumTitle);
  22. parent::Save();
  23. }
  24. }