summaryrefslogtreecommitdiffstats
path: root/includes/concert.php
diff options
context:
space:
mode:
authorAndreaChirulescu <andrea.chirulescu@gmail.com>2021-04-13 22:44:02 +0200
committerAndreaChirulescu <andrea.chirulescu@gmail.com>2021-04-13 22:44:02 +0200
commit4f0454005caa787e9fed33ca33671b7f4ada8a31 (patch)
tree450b0d03a7b80416183d028a20d3b10d54946512 /includes/concert.php
parent0c437c746a8f964bf59ae9808a2b990d144bc39e (diff)
downloadgigologadmin-4f0454005caa787e9fed33ca33671b7f4ada8a31.tar.gz
gigologadmin-4f0454005caa787e9fed33ca33671b7f4ada8a31.tar.bz2
gigologadmin-4f0454005caa787e9fed33ca33671b7f4ada8a31.zip
Concert file wizardry to split create/createAndFind,Find functions
Adjustments in admin page and import gigs to use the above adjustments
Diffstat (limited to 'includes/concert.php')
-rw-r--r--includes/concert.php46
1 files changed, 40 insertions, 6 deletions
diff --git a/includes/concert.php b/includes/concert.php
index e7165cc..7453319 100644
--- a/includes/concert.php
+++ b/includes/concert.php
@@ -42,20 +42,36 @@ if ( !class_exists('GiglogAdmin_Concert') ) {
$this->eventlink = isset($attrs->wpgconcert_event) ? $attrs->wpgconcert_event : NULL;
}
- static function find_or_create($id,$band, $venue, $cdate, $ticketlink, $eventlink)
+
+ static function find_or_create($band, $venue, $cdate, $ticketlink, $eventlink)
{
global $wpdb;
- if($id)
+ $cresults = GiglogAdmin_Concert::get($band, $venue, $cdate);
+ if ($cresults) {
+ error_log( 'DUPLICATE ROW detected: '
+ . ' BAND ID ' . $band
+ . ', VENUE ID ' . $venue
+ . ', CONCERTDATE ' . $cdate);
+ }
+ else
+ return GiglogAdmin_Concert::create($band, $venue, $cdate, $ticketlink, $eventlink);
+ }
+
+
+ static function find_cid($id)
+ { global $wpdb;
+ if(!empty($id))
{
$csql = 'SELECT * FROM wpg_concerts WHERE id="' . $id . '"';
$results = $wpdb->get_results($csql);
-
if ($results)
+ {
return new GiglogAdmin_Concert($results[0]);
+ }
}
- else {
-
- return GiglogAdmin_Concert::create($band, $venue, $cdate, $ticketlink, $eventlink);
+ else
+ { $arr = array_fill(0, 6, null);
+ return new GiglogAdmin_Concert($arr);
}
}
@@ -71,6 +87,24 @@ if ( !class_exists('GiglogAdmin_Concert') ) {
$cid = new GiglogAdmin_Concert($attrs);
$cid->save();
+ error_log( 'NEW CONCERT ADDED: '
+ . ' ID: ' . $cid -> id()
+ . ' BAND ID ' . $band
+ . ', VENUE ID ' . $venue
+ . ', CONCERTDATE ' . $cdate
+ . ', Ticket LINK ' . $ticketlink
+ . ', Event LINK ' . $eventlink);
+ GiglogAdmin_Concertlogs::add($cid->id());
+ /*the last line can be replaced by a trigger
+ CREATE TRIGGER `insertIntoPhotoLogs` AFTER INSERT ON `wpg_concerts`
+ FOR EACH ROW INSERT INTO wpg_concertlogs (
+ wpg_concertlogs.id,
+ wpg_concertlogs.wpgcl_concertid,
+ wpg_concertlogs.wpgcl_status)
+
+ VALUES
+ (null, new.id, 1)
+ */
return $cid;
}