diff --git a/index.js b/index.js index f90f89b..efc6985 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,8 @@ const db = new Dexie("Team Tracking App"); //trap was in there twice throwing errors so I removed the last one of them (2nd to last entry) -db.version(2).stores({ - teams: "++id, teamname, globalid, teamnumber, teamschool, alliancescore, moreinfo, startingpos, Leaveszone, scores1amp, scores1speaker, picksup, scores2amp, scores2speaker, preferredScoringMethod, preferredIntakeMethod, prefintake, spotlight, trap, alone, hangsWithAnother, attemptsSpotlight, coop", +db.version(3).stores({ + teams: "++indexid, teamname, globalid, teamnumber, teamschool, alliancescore, moreinfo, startingpos, Leaveszone, scores1amp, scores1speaker, picksup, scores2amp, scores2speaker, preferredScoringMethod, preferredIntakeMethod, prefintake, spotlight, trap, alone, hangsWithAnother, attemptsSpotlight, coop", matches: "++id, rank, matchnumber, count1, count2, count3, count4, count5, count6, count7, stage, hangs, harmony, otherinfo" }); // Version numbers must be changed whenever database objects (schema) are edited? See "Modify Schema" in https://dexie.org/docs/Tutorial/Understanding-the-basics diff --git a/pages/matchinfo.js b/pages/matchinfo.js index 5ac44ed..8f2ec73 100644 --- a/pages/matchinfo.js +++ b/pages/matchinfo.js @@ -143,9 +143,9 @@ plusBtn7.addEventListener('click', function() { // DATABASE --------------------------------------------------------------- const db = new Dexie("Team Tracking App"); -db.version(2).stores({ - teams: "++id, teamname, globalid, teamnumber, teamschool, alliancescore, moreinfo, startingpos, Leaveszone, scores1amp, scores1speaker, picksup, scores2amp, scores2speaker, preferredScoringMethod, preferredIntakeMethod, prefintake, spotlight, trap, alone, hangsWithAnother, attemptsSpotlight, coop", - matches: "++id, rank, matchnumber, count1, count2, count3, count4, count5, count6, count7, stage, hangs, harmony, otherinfo" +db.version(3).stores({ + teams: "++indexid, teamname, globalid, teamnumber, teamschool, alliancescore, moreinfo, startingpos, Leaveszone, scores1amp, scores1speaker, picksup, scores2amp, scores2speaker, preferredScoringMethod, preferredIntakeMethod, prefintake, spotlight, trap, alone, hangsWithAnother, attemptsSpotlight, coop", + matches: "++indexid, rank, matchnumber, count1, count2, count3, count4, count5, count6, count7, stage, hangs, harmony, otherinfo" }); // Version numbers must be changed whenever database objects (schema) are edited? See "Modify Schema" in https://dexie.org/docs/Tutorial/Understanding-the-basics // db = database diff --git a/pages/teamdetails.js b/pages/teamdetails.js index 5d8b42a..d32ef36 100644 --- a/pages/teamdetails.js +++ b/pages/teamdetails.js @@ -1,9 +1,21 @@ // Global Dexie database initialization const db = new Dexie("Team Tracking App"); -db.version(2).stores({ - teams: "++id, teamname, globalid, teamnumber, teamschool, alliancescore, moreinfo, startingpos, Leaveszone, scores1amp, scores1speaker, picksup, scores2amp, scores2speaker, preferredScoringMethod, preferredIntakeMethod, prefintake, spotlight, trap, alone, hangsWithAnother, attemptsSpotlight, coop", - matches: "++id, rank, matchnumber, count1, count2, count3, count4, count5, count6, count7, stage, hangs, harmony, otherinfo" +db.version(3).stores({ + teams: "++indexid, teamname, globalid, teamnumber, teamschool, alliancescore, moreinfo, startingpos, Leaveszone, scores1amp, scores1speaker, picksup, scores2amp, scores2speaker, preferredScoringMethod, preferredIntakeMethod, prefintake, spotlight, trap, alone, hangsWithAnother, attemptsSpotlight, coop", + matches: "++indexid, rank, matchnumber, count1, count2, count3, count4, count5, count6, count7, stage, hangs, harmony, otherinfo" }); + + + + + + //i CHANGED ID TO INDEXID AS ID WAS CONFLICTING WITH THE AUTO INCREMENTED ID IN THE TABLE ON THE SQL SERVER *********************** + + + + + + // Version numbers must be changed whenever database objects (schema) are edited? See "Modify Schema" in https://dexie.org/docs/Tutorial/Understanding-the-basics diff --git a/php/db.php b/php/db.php index 1873110..acd589e 100644 --- a/php/db.php +++ b/php/db.php @@ -1,5 +1,17 @@ '' ]; -try { - // Connection using PDO - $conn = new PDO("sqlsrv:server = tcp:scounting7127.database.windows.net,1433; Database = scouting7127", "CloudSAcaf36d4a", "3P&tLBL7Xc7L6R5p"); - $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $response['connection'] = 'Connected to database successfully'; - - // Assuming $data is an array of teams - foreach ($data as $team) { - $columns = array_keys($team); - $placeholders = array_map(function($value) { return '?'; }, $team); - $sql = "INSERT INTO teams (" . implode(", ", $columns) . ") VALUES (" . implode(", ", $placeholders) . ")"; +// try { +// // Connection using PDO +// $conn = new PDO("sqlsrv:server = tcp:scounting7127.database.windows.net,1433; Database = scouting_7127", "CloudSAcaf36d4a", "3HKEkfjD3Q@!S#r9"); //CloudSAcaf36d4a +// $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +// $response['connection'] = 'Connected to database successfully'; + +// // Assuming $data is an array of teams +// foreach ($data as $team) { +// $columns = array_keys($team); +// $placeholders = array_map(function($value) { return '?'; }, $team); +// $sql = "INSERT INTO teams (" . implode(", ", $columns) . ") VALUES (" . implode(", ", $placeholders) . ")"; - $stmt = $conn->prepare($sql); - if ($stmt->execute(array_values($team))) { - $response['success'] = true; - $response['data'][] = 'Inserted: ' . json_encode($sql); - } else { - $response['debug'] = true; - $response['data'][] = 'Inserted: ' . json_encode($sql); - } - } -} catch (PDOException $e) { - $response['debug'] = 'Error connecting to SQL Server.'; - $response['data'] = $e->getMessage(); -} catch (Exception $e) { - $response['debug'] = 'An error occurred.'; - $response['data'] = $e->getMessage(); -} +// $stmt = $conn->prepare($sql); +// if ($stmt->execute(array_values($team))) { +// $response['success'] = true; +// $response['data'][] = 'Inserted: ' . json_encode($sql); +// } else { +// $response['debug'] = true; +// $response['data'][] = 'Inserted: ' . json_encode($sql); +// } +// } +// } catch (PDOException $e) { +// $response['debug'] = 'Error connecting to SQL Server.'; +// $response['data'] = $e->getMessage(); +// } catch (Exception $e) { +// $response['debug'] = 'An error occurred.'; +// $response['data'] = $e->getMessage(); +// } echo json_encode($response); ?>