summaryrefslogtreecommitdiffstats
path: root/includes/band.php
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-04-15 21:50:58 +0200
committerHarald Eilertsen <haraldei@anduin.net>2021-04-15 21:52:05 +0200
commit7160aacdc83cfcef9ffd795cec7e9397bfbb3698 (patch)
tree69e7ace6f3a689de2150a8bea16fe29b78753b3a /includes/band.php
parente59f12fd21af5489b8889aa4c3ab5a90a9b317a9 (diff)
downloadgigologadmin-7160aacdc83cfcef9ffd795cec7e9397bfbb3698.tar.gz
gigologadmin-7160aacdc83cfcef9ffd795cec7e9397bfbb3698.tar.bz2
gigologadmin-7160aacdc83cfcef9ffd795cec7e9397bfbb3698.zip
Make Band::create return band object, not just id.
Diffstat (limited to 'includes/band.php')
-rw-r--r--includes/band.php21
1 files changed, 10 insertions, 11 deletions
diff --git a/includes/band.php b/includes/band.php
index ad5ce28..13a816f 100644
--- a/includes/band.php
+++ b/includes/band.php
@@ -20,10 +20,10 @@ if ( !class_exists('GiglogAdmin_Band') ) {
$this->country = isset($attrs->country) ? $attrs->country : 'NO';
}
- static function create($bandname, $country)
+ static function create($bandname, $country = 'NO')
{
global $wpdb;
- if (empty($country)) $country = 'NO';
+
$bandsql = 'SELECT id FROM wpg_bands WHERE upper(wpgband_name)="' . $bandname . '" and wpgband_country = "'.$country.'"';
$results = $wpdb->get_results($bandsql);
$attrs = new stdClass();
@@ -37,20 +37,19 @@ if ( !class_exists('GiglogAdmin_Band') ) {
}
else
{
+ $attrs->id = '';
- $attrs->id = '';
-
- $bid = new GiglogAdmin_Band($attrs);
- $bid->save();
+ $bid = new GiglogAdmin_Band($attrs);
+ $bid->save();
- error_log( 'NEW BAND ADDED: '
- . ' ID: ' . $bid -> id()
- . ' BAND NAME ' . $bandname
- . ', COUNTRY ' . $country);
+ error_log( 'NEW BAND ADDED: '
+ . ' ID: ' . $bid -> id()
+ . ' BAND NAME ' . $bandname
+ . ', COUNTRY ' . $country);
}
- return ($bid->id());
+ return $bid;
}