mirror of
https://github.com/standardebooks/web.git
synced 2025-07-18 20:36:38 -04:00
Update PropertiesBase to new patterns and improve static analysis checks
This commit is contained in:
parent
5f0b57f7e9
commit
6c8414f844
33 changed files with 335 additions and 148 deletions
|
@ -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');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue