mirror of
https://github.com/standardebooks/web.git
synced 2025-07-14 02:21:55 -04:00
Add poll system for Patrons Circle
This commit is contained in:
parent
3555d53615
commit
2ef5ce6551
44 changed files with 717 additions and 98 deletions
27
lib/PollItem.php
Normal file
27
lib/PollItem.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?
|
||||
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::Query('select count(*) as VoteCount from Votes v inner join PollItems pi on v.PollItemId = pi.PollItemId where pi.PollItemId = ?', [$this->PollItemId]))[0]->VoteCount;
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue