diff options
| author | Syndamia <kamen@syndamia.com> | 2025-02-01 17:06:10 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2025-02-01 17:06:10 +0200 |
| commit | 02995bfe9827c0c329c9c397411d83bd6918d096 (patch) | |
| tree | 5b44dfb3c18000e201da40976f2f51158c8fc423 /models | |
| parent | 61c5b503352c983d4e532b5a59e2ae913e53e70c (diff) | |
| download | nowayforward_human-02995bfe9827c0c329c9c397411d83bd6918d096.tar nowayforward_human-02995bfe9827c0c329c9c397411d83bd6918d096.tar.gz nowayforward_human-02995bfe9827c0c329c9c397411d83bd6918d096.zip | |
feat: Add XAMPP setup
Diffstat (limited to 'models')
| -rw-r--r-- | models/database.php | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/models/database.php b/models/database.php index dc177e8..8efd20c 100644 --- a/models/database.php +++ b/models/database.php @@ -62,10 +62,21 @@ abstract class Table { } static protected function connect() : PDO { - $conn = new PDO( - "mysql:unix_socket=" . getenv('MYSQL_UNIX_SOCKET') . ";dbname=nwfh", - getenv('USER'), - ""); + $unix_socket = getenv('MYSQL_UNIX_SOCKET'); + $conn = null; + // Windows support + if ($unix_socket == '') { + $conn = new PDO( + "mysql:host=" . getenv('SERVER') . ";port=" . getenv('PORT') . ";dbname=nwfh", + getenv('USER'), + getenv('PASSWORD')); + } + else { + $conn = new PDO( + "mysql:unix_socket=$unix_socket;dbname=nwfh", + getenv('USER'), + getenv('PASSWORD')); + } // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); return $conn; |
