Skip to content

Commit

Permalink
2 add isolation level to transactions (#3)
Browse files Browse the repository at this point in the history
* disable autocommit, isolation level serializable

* update to version 1.1
  • Loading branch information
intragart authored Jan 5, 2023
1 parent ec539c9 commit 8a2010f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1] - 2023-01-05

### Changed

- Disabled autocommit when transactions are used
- Added isolation level serializable to all transactions

## [1.0] - 2023-01-01

### Added

- Initial Release of the Project

[1.1]: https://github.com/intragart/Shared-Household-Expenses/compare/v1.0...v1.1
[1.0]: https://github.com/intragart/Shared-Household-Expenses/releases/tag/v1.0
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.0
v1.1
7 changes: 6 additions & 1 deletion webapp/www/api/delete-purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@
$db_settings = get_db_login("admin");

// connect to database and start a transaction
$db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]);
$db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]);

// disable autocommit and set isolation level to serialize
$db->autocommit(false);
$db->query("SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE");

$db->begin_transaction(MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT);

try {
Expand Down
7 changes: 6 additions & 1 deletion webapp/www/api/insert-purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ function getRetailerID ($retailer_name) {
$db_settings = get_db_login("admin");

// connect to database and start a transaction
$db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]);
$db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]);

// disable autocommit and set isolation level to serialize
$db->autocommit(false);
$db->query("SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE");

$db->begin_transaction(MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT);

try {
Expand Down
7 changes: 6 additions & 1 deletion webapp/www/api/insert-user.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@
$db_settings = get_db_login("admin");

// connect to database and start a transaction
$db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]);
$db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]);

// disable autocommit and set isolation level to serialize
$db->autocommit(false);
$db->query("SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE");

$db->begin_transaction(MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT);

try {
Expand Down
7 changes: 6 additions & 1 deletion webapp/www/api/update-purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ function getRetailerID ($retailer_name) {
$db_settings = get_db_login("admin");

// connect to database and start a transaction
$db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]);
$db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]);

// disable autocommit and set isolation level to serialize
$db->autocommit(false);
$db->query("SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE");

$db->begin_transaction(MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT);

try {
Expand Down
7 changes: 6 additions & 1 deletion webapp/www/api/update-user.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@
$db_settings = get_db_login("admin");

// connect to database and start a transaction
$db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]);
$db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]);

// disable autocommit and set isolation level to serialize
$db->autocommit(false);
$db->query("SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE");

$db->begin_transaction(MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT);

try {
Expand Down

0 comments on commit 8a2010f

Please sign in to comment.