_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; } // *********** // ORM METHODS // *********** public static function Get(?int $pollItemId): PollItem{ if($pollItemId === null ){ throw new Exceptions\InvalidPollItemException(); } $result = Db::Query('SELECT * from PollItems where PollItemId = ?', [$pollItemId], 'PollItem'); if(sizeof($result) == 0){ throw new Exceptions\InvalidPollItemException(); } return $result[0]; } }