예제 #1
0
 public static function getAllReviews()
 {
     // Return all of the reviews as an array of Review objects
     $query = "SELECT Reviews.reviewId, Reviews.submissionId, Users.userName,\r\n\t   \t\t            Reviews.score, Reviews.review \r\n\t   \t\t             FROM Reviews LEFT JOIN Users ON Reviews.userId = Users.userId ";
     $reviews = array();
     try {
         $db = Database::getDB();
         $statement = $db->prepare($query);
         $statement->execute();
         $reviews = ReviewsDB::getReviewsArray($statement->fetchAll(PDO::FETCH_ASSOC));
         $statement->closeCursor();
     } catch (PDOException $e) {
         // Not permanent error handling
         echo "<p>Error getting all reviews " . $e->getMessage() . "</p>";
     }
     return $reviews;
 }
예제 #2
0
 public static function getReviewsBy($type = null, $value = null)
 {
     // Returns Review objects whose $type field has value $value
     $reviewRows = ReviewsDB::getReviewRowSetsBy($type, $value);
     return ReviewsDB::getReviewsArray($reviewRows);
 }