diff --git a/load/qsladifloadcommit.php b/load/qsladifloadcommit.php index d1361dd..3d61897 100644 --- a/load/qsladifloadcommit.php +++ b/load/qsladifloadcommit.php @@ -122,19 +122,38 @@ # get the id of the last log $sql = sprintf("SELECT LAST_INSERT_ID()"); + +# Insertion transaction $res = $conn->query($sql); list($logid) = $res->fetch_row(); -# insert the actual transaction +$conn->begin_transaction(); $vals = base64_decode($transdata); $vals = preg_replace("/\)/",",$logid)",$vals); -$sql = sprintf("INSERT INTO qsos (callsign,band,freq,rstrcvd,qsodate,timeon,operator,station,mode,county,logid) VALUES %s", - $vals); -if( $conn->query($sql) === false ){ - printf("
Could not write the QSOs to the DB. Transaction +$inserts = explode("),(", $vals); +foreach( $inserts as $insert){ + $insert = preg_replace("/[\(\)]/", "", $insert); + $sql = sprintf("INSERT INTO qsos (callsign,band,freq,rstrcvd,qsodate," . + "timeon,operator,station,mode,county,logid) VALUES (%s)", + $insert); + $res = $conn->query($sql); + if( $res === false ){ + printf("
Individual transaction insert failed due to bad input
"); + printf("%s", $conn->error); + printf("
%s", $sql); + printf("Transaction ID is:
Could not write the QSO transaction to the DB. Transaction
ID is:
%s
Could not unlock transaction. Transaction diff --git a/qsl.sql b/qsl.sql index 4f1bf18..0a08fe6 100644 --- a/qsl.sql +++ b/qsl.sql @@ -56,10 +56,10 @@ CREATE TABLE `qsos` ( `timeon` char(14) DEFAULT NULL, `operator` char(10) NOT NULL, `station` char(10) NOT NULL, - `mode` char(10) DEFAULT NULL, + `mode` char(30) DEFAULT NULL, `tstamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `logid` int(11) NOT NULL, - `county` char(30) DEFAULT NULL, + `county` varchar(255) DEFAULT NULL, PRIMARY KEY (`qsoid`), KEY `callsign_idx` (`callsign`) ) ENGINE=InnoDB AUTO_INCREMENT=1883 DEFAULT CHARSET=latin1; @@ -88,4 +88,6 @@ CREATE TABLE `trans` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2017-06-04 16:01:21 +ALTER TABLE `qsos` MODIFY `mode` char(30) DEFAULT NULL; +ALTER TABLE `qsos` MODIFY `county` varchar(255) DEFAULT NULL; +