array(6) { [0]=> string(3) "all" [1]=> string(7) "jul-sep" [2]=> string(4) "2020" [3]=> array(0) { } [4]=> NULL [5]=> NULL } SELECT destinations.destination, destinations.period, destinations.year, destinations.cruiseline_id, destinations.cruiseship_id, IFNULL(reviewAverage.food, 0) as food, IFNULL(reviewAverage.state_room, 0) as state_room, IFNULL(reviewAverage.fitness, 0) as fitness, IFNULL(reviewAverage.value_for_money, 0) as value_for_money, IFNULL(reviewAverage.suggested, 0) as suggested, IFNULL(reviewAverage.young_travellers, 0) as young_travellers, IFNULL(reviewAverage.entertiments, 0) as entertiments, cruiseship.name as cruiseship_name, cruiseship.average_score as average_score, cruiseship.short_name as cruiseship_short_name, cruiseline.name as cruiseline_name, cruiseline.short_name as cruiseline_short_name from destinations LEFT JOIN cruiseship ON cruiseship.id = destinations.cruiseship_id LEFT JOIN cruiseline ON cruiseline.id = destinations.cruiseline_id LEFT JOIN ( SELECT AVG(review_average.food) as food, AVG(review_average.state_room) as state_room, AVG(review_average.entertiments) as entertiments, AVG(review_average.fitness) as fitness, AVG(review_average.young_travellers) as young_travellers, AVG(review_average.value_for_money) as value_for_money, AVG(review_average.suggested) as suggested, review.cruiseship_id FROM review_average left join review on review_average.review_id = review.id group by review.cruiseship_id ) reviewAverage on reviewAverage.cruiseship_id = destinations.cruiseship_id WHERE destinations.expired = 0 AND destinations.period = :period AND destinations.year = :year ORDER BY destinations.year ASC , cruiseship.average_score DESC