mirror of
https://github.com/standardebooks/web.git
synced 2025-07-07 07:10:29 -04:00
27 lines
719 B
PHP
27 lines
719 B
PHP
<?
|
|
class PollItem extends PropertiesBase{
|
|
public $PollItemId;
|
|
public $PollId;
|
|
public $Name;
|
|
public $Description;
|
|
protected $VoteCount = null;
|
|
protected $Poll = null;
|
|
|
|
protected function GetVoteCount(): int{
|
|
if($this->VoteCount === null){
|
|
$this->VoteCount = Db::QueryInt('select count(*) from Votes v inner join PollItems pi on v.PollItemId = pi.PollItemId where pi.PollItemId = ?', [$this->PollItemId]);
|
|
}
|
|
|
|
return $this->VoteCount;
|
|
}
|
|
|
|
public static function Get(?int $pollItemId): PollItem{
|
|
$result = Db::Query('SELECT * from PollItems where PollItemId = ?', [$pollItemId], 'PollItem');
|
|
|
|
if(sizeof($result) == 0){
|
|
throw new Exceptions\InvalidPollItemException();
|
|
}
|
|
|
|
return $result[0];
|
|
}
|
|
}
|