From df7c0a5dbf772a535c383f31fab578b5f82cb337 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sun, 9 May 2021 17:18:46 +0200 Subject: New method Venue::get to get venue by id --- includes/venue.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/includes/venue.php b/includes/venue.php index aaf51d0..f9f7e4f 100644 --- a/includes/venue.php +++ b/includes/venue.php @@ -28,6 +28,22 @@ if ( !class_exists('GiglogAdmin_Venue') ) { $this->webpage = isset($attrs->wpgvenue_webpage) ? $attrs->wpgvenue_webpage : NULL; } + /** + * Get venue by given id. + * + * @param int $id. + * @return null|self. + */ + static function get(int $id) : ?self + { + global $wpdb; + + $query = $wpdb->prepare('SELECT * from wpg_venues WHERE id = %d', $id); + $results = $wpdb->get_results($query); + + return $results ? new GiglogAdmin_Venue($results[0]) : NULL; + } + static function create($name, $city = 'Oslo'): self { $venue = new GiglogAdmin_Venue((object) [ -- cgit v1.2.3