Code Duplication    Length = 23-26 lines in 4 locations

require/class.Spotter.php 4 locations

@@ 3911-3933 (lines=23) @@
3908
	* @return Array the airline country list
3909
	*
3910
	*/
3911
	public function countAllAirlineCountries($limit = true)
3912
	{
3913
		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3914
		 			FROM spotter_output
3915
					WHERE spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA' 
3916
					GROUP BY spotter_output.airline_country
3917
					ORDER BY airline_country_count DESC";
3918
		if ($limit) $query .= " LIMIT 10 OFFSET 0";
3919
      
3920
		$sth = $this->db->prepare($query);
3921
		$sth->execute();
3922
3923
		$airline_array = array();
3924
		$temp_array = array();
3925
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3926
		{
3927
			$temp_array['airline_country_count'] = $row['airline_country_count'];
3928
			$temp_array['airline_country'] = $row['airline_country'];
3929
3930
			$airline_array[] = $temp_array;
3931
		}
3932
		return $airline_array;
3933
	}
3934
3935
	/**
3936
	* Gets all number of flight over countries
@@ 4889-4914 (lines=26) @@
4886
	* @return Array the aircraft list
4887
	*
4888
	*/
4889
	public function countAllAircraftManufacturers()
4890
	{
4891
		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4892
                    FROM spotter_output 
4893
                    WHERE spotter_output.aircraft_manufacturer <> '' AND spotter_output.aircraft_manufacturer <> 'Not Available' 
4894
                    GROUP BY spotter_output.aircraft_manufacturer
4895
					ORDER BY aircraft_manufacturer_count DESC
4896
					LIMIT 10";
4897
      
4898
		
4899
		$sth = $this->db->prepare($query);
4900
		$sth->execute();
4901
      
4902
		$manufacturer_array = array();
4903
		$temp_array = array();
4904
        
4905
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4906
		{
4907
			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
4908
			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
4909
          
4910
			$manufacturer_array[] = $temp_array;
4911
		}
4912
4913
		return $manufacturer_array;
4914
	}
4915
	
4916
	
4917
	
@@ 6450-6475 (lines=26) @@
6447
	* @return Array the airport departure list
6448
	*
6449
	*/
6450
	public function countAllDepartureCountries()
6451
	{
6452
		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6453
								FROM spotter_output 
6454
                    WHERE spotter_output.departure_airport_country <> '' AND spotter_output.departure_airport_icao <> 'NA' 
6455
                    GROUP BY spotter_output.departure_airport_country
6456
					ORDER BY airport_departure_country_count DESC
6457
					LIMIT 10 OFFSET 0";
6458
      
6459
		
6460
		$sth = $this->db->prepare($query);
6461
		$sth->execute();
6462
      
6463
		$airport_array = array();
6464
		$temp_array = array();
6465
        
6466
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6467
		{
6468
			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
6469
			$temp_array['airport_departure_country'] = $row['departure_airport_country'];
6470
          
6471
			$airport_array[] = $temp_array;
6472
		}
6473
6474
		return $airport_array;
6475
	}
6476
	
6477
	
6478
	/**
@@ 6484-6509 (lines=26) @@
6481
	* @return Array the airport arrival list
6482
	*
6483
	*/
6484
	public function countAllArrivalCountries($limit = true)
6485
	{
6486
		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6487
								FROM spotter_output 
6488
                    WHERE spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA' 
6489
                    GROUP BY spotter_output.arrival_airport_country
6490
					ORDER BY airport_arrival_country_count DESC";
6491
		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6492
      
6493
		
6494
		$sth = $this->db->prepare($query);
6495
		$sth->execute();
6496
      
6497
		$airport_array = array();
6498
		$temp_array = array();
6499
        
6500
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6501
		{
6502
			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
6503
			$temp_array['airport_arrival_country'] = $row['arrival_airport_country'];
6504
          
6505
			$airport_array[] = $temp_array;
6506
		}
6507
6508
		return $airport_array;
6509
	}
6510
6511
6512