summaryrefslogtreecommitdiffstats
path: root/includes/band.php
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-04-21 20:45:52 +0200
committerHarald Eilertsen <haraldei@anduin.net>2021-04-21 20:45:52 +0200
commitf2b63c7e20118bfaefe8629f61d45a08e771f852 (patch)
tree1961405d76f114358935ac7e3056c25467275cd2 /includes/band.php
parent23da25c5f3594adabe3a4d4effe8bc0f4eca6832 (diff)
downloadgigologadmin-f2b63c7e20118bfaefe8629f61d45a08e771f852.tar.gz
gigologadmin-f2b63c7e20118bfaefe8629f61d45a08e771f852.tar.bz2
gigologadmin-f2b63c7e20118bfaefe8629f61d45a08e771f852.zip
Fix Bands class constructor.
The expected attributes did not have names corresponding with the table columns, which meant that creating a band directly from a returned table row did not produce the expected result.
Diffstat (limited to 'includes/band.php')
-rw-r--r--includes/band.php15
1 files changed, 10 insertions, 5 deletions
diff --git a/includes/band.php b/includes/band.php
index 47b663c..14daa18 100644
--- a/includes/band.php
+++ b/includes/band.php
@@ -12,12 +12,17 @@ if ( !class_exists('GiglogAdmin_Band') ) {
private $bandname;
private $country;
-
+ /*
+ * Constructs a new band object from an array of attributes.
+ * The attributes are expected to be named as in the database,
+ * so this constructor can be used to construct the object
+ * directly from the database row.
+ */
public function __construct($attrs = [])
{
$this->id = isset($attrs->id) ? $attrs->id : NULL;
- $this->bandname = isset($attrs->bandname) ? $attrs->bandname : NULL;
- $this->country = isset($attrs->country) ? $attrs->country : 'NO';
+ $this->bandname = isset($attrs->wpgband_name) ? $attrs->wpgband_name : NULL;
+ $this->country = isset($attrs->wpgband_country) ? $attrs->wpgband_country : 'NO';
}
static function create($bandname, $country = 'NO')
@@ -26,8 +31,8 @@ if ( !class_exists('GiglogAdmin_Band') ) {
if ( ! $band ) {
$band = new GiglogAdmin_Band((object) [
- 'bandname' => $bandname,
- 'country' => $country,
+ 'wpgband_name' => $bandname,
+ 'wpgband_country' => $country,
]);
$band->save();