public function countYellowTwoCards() { $sel = new \Selector('Cards'); $sel->filter([['color', '=', 3]]); $sel->count(); $result = $this->select($sel); if (count($result) != 1) { throw new exception('Error while counting cards'); } return $result[0]['COUNT(*)']; }