Skip to content

Commit a2428e0

Browse files
committed
Update MySQLConnection.php
1 parent 38d4838 commit a2428e0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

berry/mysql/MySQLConnection.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class MySQLConnection
44
{
55

66
private mysqli $fLink; // The mysqli link with the selected MySQL database
7+
private bool $fConnectionIsOpen = false;
78

89
/**
910
* Constructs a new MySQLConnection
@@ -26,6 +27,7 @@ public function __construct(string $serverIP, string $database, string $user, st
2627
{
2728
$this->fLink->set_charset($charset);
2829
}
30+
$this->fConnectionIsOpen = true;
2931
}
3032

3133
/**
@@ -44,7 +46,11 @@ public function EscapeString(string $string): string
4446
*/
4547
public function Close(): void
4648
{
47-
$this->fLink->close();
49+
if ($this->fConnectionIsOpen)
50+
{
51+
$this->fLink->close();
52+
$this->fConnectionIsOpen = false;
53+
}
4854
}
4955

5056
/**
@@ -55,7 +61,6 @@ public function getLink(): mysqli
5561
{
5662
return $this->fLink;
5763
}
58-
5964
}
6065

6166
?>

0 commit comments

Comments
 (0)