summaryrefslogtreecommitdiffstats
path: root/includes/concert.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/concert.php')
-rw-r--r--includes/concert.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/includes/concert.php b/includes/concert.php
index e3c32e8..050c924 100644
--- a/includes/concert.php
+++ b/includes/concert.php
@@ -170,6 +170,35 @@ if ( !class_exists('GiglogAdmin_Concert') ) {
return $wpdb->get_results($sql);
}
+
+ public static function find_concerts_in(string $city) : 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);
+
+ $results = $wpdb->get_results($query);
+
+ return array_map(function($c) { return new GiglogAdmin_Concert($c); }, $results);
+ }
+
+ public static function find_concerts_at(GiglogAdmin_Venue $venue) : 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_concerts.venue = ' . $wpdb->prepare('%d', $venue->id());
+
+ $results = $wpdb->get_results($query);
+
+ return array_map(function($c) { return new GiglogAdmin_Concert($c); }, $results);
+ }
+
public function save(): void
{
global $wpdb;