From ae72f1b2f0c73ded5277300f0d15914e6e10ecae Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Mon, 10 May 2021 10:45:04 +0200 Subject: Make it possible to list all concerts. --- includes/concert.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'includes/concert.php') diff --git a/includes/concert.php b/includes/concert.php index 050c924..455bc82 100644 --- a/includes/concert.php +++ b/includes/concert.php @@ -171,14 +171,17 @@ if ( !class_exists('GiglogAdmin_Concert') ) { } - public static function find_concerts_in(string $city) : array + public static function find_concerts_in(?string $city = null) : array { global $wpdb; $query = 'SELECT wpg_concerts.*, wpg_venues.wpgvenue_name, wpg_venues.wpgvenue_city ' . 'FROM wpg_concerts ' - . 'INNER JOIN wpg_venues ON wpg_concerts.venue = wpg_venues.id ' - . 'WHERE wpg_venues.wpgvenue_city = ' . $wpdb->prepare('%s', $city); + . 'INNER JOIN wpg_venues ON wpg_concerts.venue = wpg_venues.id '; + + if ( $city ) { + $query .= 'WHERE wpg_venues.wpgvenue_city = ' . $wpdb->prepare('%s', $city); + } $results = $wpdb->get_results($query); -- cgit v1.2.3