Update PropertiesBase to new patterns and improve static analysis checks

This commit is contained in:
Alex Cabal 2022-06-30 13:23:05 -05:00
parent 5f0b57f7e9
commit 6c8414f844
33 changed files with 335 additions and 148 deletions

View file

@ -1,20 +1,35 @@
<?
/**
* @property int $VoteCount
* @property Poll $Poll
*/
class PollItem extends PropertiesBase{
public $PollItemId;
public $PollId;
public $Name;
public $Description;
protected $VoteCount = null;
protected $Poll = null;
protected $_VoteCount = null;
protected $_Poll = null;
// *******
// GETTERS
// *******
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]);
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;
return $this->_VoteCount;
}
// ***********
// ORM METHODS
// ***********
public static function Get(?int $pollItemId): PollItem{
$result = Db::Query('SELECT * from PollItems where PollItemId = ?', [$pollItemId], 'PollItem');