public function getAverageRating() { $c = new Criteria; $c->addSelectColumn('avg(' . RatingPeer::RATING . ')'); $c->add(RatingPeer::ID, $this->getId()); $stmt = RatingPeer::doSelectStmt($c); $average = $stmt->fetchAll(PDO::FETCH_COLUMN); if(array_key_exists(0, $average)) { return floatval($average[0]); } else { return 0; } }
Nenhum comentário:
Postar um comentário