Skip to content

Commit

Permalink
address Brady comments for mysql connection and sql table structure fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sjpadgett committed Jun 20, 2024
1 parent 7fe3fc2 commit 5231631
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ CREATE TABLE `weno_pharmacy` (
`State_Wide_Mail_Order` varchar(15) NOT NULL,
`Mail_Order_US_State_Serviced` varchar(255) DEFAULT NULL,
`Mail_Order_ US_Territories_Serviced` varchar(255) DEFAULT NULL,
`On_WENO` tinytext DEFAULT NULL,
`On_WENO` tinyint DEFAULT NULL,
`24HR` varchar(3) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `ncpdp` (`NCPDP_safe`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ public function processWenoPharmacyCsv($filePath, bool $isInsertOnly = true): fa
$sql = "TRUNCATE TABLE weno_pharmacy";
sqlStatement($sql);
}

// Database configuration. Create connection.
$connect = new mysqli($GLOBALS["host"], $GLOBALS["login"], $GLOBALS["pass"], $GLOBALS["dbase"]);
// Use existing connection.
// Compared to creating a new connection, this method is slower by 3 seconds.
// Using the sqlStatement() method is even slower by 10 seconds. That's 13 seconds slower overall.
$connect = $GLOBALS['dbh'];
if ($connect->connect_error) {
$wenoLog->insertWenoLog("pharmacy", "Connection Failed.");
error_log("Connection failed: " . $connect->connect_error);
Expand Down Expand Up @@ -140,7 +141,7 @@ public function processWenoPharmacyCsv($filePath, bool $isInsertOnly = true): fa
}

$connect->commit();
$connect->close();
// $connect->close();
} catch (Exception $e) {
$connect->rollback();
error_log(text($e->getMessage()));
Expand Down
2 changes: 1 addition & 1 deletion interface/modules/custom_modules/oe-module-weno/table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CREATE TABLE `weno_pharmacy` (
`State_Wide_Mail_Order` varchar(15) NOT NULL,
`Mail_Order_US_State_Serviced` varchar(255) DEFAULT NULL,
`Mail_Order_ US_Territories_Serviced` varchar(255) DEFAULT NULL,
`On_WENO` tinytext DEFAULT NULL,
`On_WENO` tinyint DEFAULT NULL,
`24HR` varchar(3) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `ncpdp` (`NCPDP_safe`)
Expand Down

0 comments on commit 5231631

Please sign in to comment.