diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2021-05-09 17:18:46 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2021-05-09 17:18:46 +0200 |
commit | df7c0a5dbf772a535c383f31fab578b5f82cb337 (patch) | |
tree | a9a04f95957132b966d73b95ef1ad83a05848c9e /includes/venue.php | |
parent | b58211e3617f4125567c313736f5ed0bcea7313c (diff) | |
download | gigologadmin-df7c0a5dbf772a535c383f31fab578b5f82cb337.tar.gz gigologadmin-df7c0a5dbf772a535c383f31fab578b5f82cb337.tar.bz2 gigologadmin-df7c0a5dbf772a535c383f31fab578b5f82cb337.zip |
New method Venue::get to get venue by id
Diffstat (limited to 'includes/venue.php')
-rw-r--r-- | includes/venue.php | 16 |
1 files changed, 16 insertions, 0 deletions
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) [ |