<?php
class Project extends DBObject {
	public $Category;
	public $Images;
	
	public function __construct($id=0) {
		parent::__construct("projects", "id", $id);
		
		$this->Category=new ProjectCategory($this->ProjectCategoryId);
		
		$idList=explode(",", $this->ProjectImages);
		$this->Images=array();
		foreach ($idList as $id)
			$this->Images[]=new Image($id);
	}
	
	public function Save(){
		$images=array();
		foreach ($this->Images as $img)
			$images[]=$img->ImageId;
		$this->ProjectImages=implode(",", $images);
		parent::Save();
	}
	
	public function GetIcon(){
		return new Image($this->ProjectIcon);
	}
}
