/**
  * count the number of local author that joins monthly
  * @param Integer $month month number
  * @param Integer $year  year
  *
  * @return Integer
  */
 public function countMonthlyJoinedLocalAuthor($month, $year)
 {
     $isLocalAuthor = $this->constants->get('LOCAL_AUTHOR');
     $sql = "SELECT count(author.id) FROM local_author author WHERE MONTH(author.date_joined) = {$month} AND YEAR(author.date_joined) = {$year} AND ( author.is_local_author = 1 )";
     $stmt = $this->connection->prepare($sql);
     $stmt->execute();
     $count = $stmt->fetch(PDO::FETCH_NUM);
     return $count[0];
 }
 /**
  * Saves the posted review for local author
  * @return Array
  */
 public function saveLocalAuthorReview()
 {
     // $status = $this->constants->get('unviewed_review');
     $status = $this->constants->get('approved_review');
     $content = trim($this->params['content']);
     $localAuthorId = $this->params['local_author'];
     $localAuthor = $country = $this->entityManager->find('BugglMainBundle:LocalAuthor', $localAuthorId);
     if (is_null($localAuthor)) {
         return array('sucess' => false);
     }
     $reviewer = $this->securityContext->getToken()->getUser();
     $review = new \Buggl\MainBundle\Entity\LocalAuthorReview();
     $review->setReviewer($reviewer)->setContent($content)->setDateAdded(new \DateTime(date('Y-m-d H:i:s', time())))->setStatus($status)->setLocalAuthor($localAuthor);
     $this->entityManager->persist($review);
     $this->entityManager->flush();
     return array('success' => true, 'review' => $review);
 }