Skip to content

Commit f0ee397

Browse files
committed
added a seperated non-network file
1 parent 79efbe6 commit f0ee397

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

.env.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ APP_URL=http://localhost
77
LOG_CHANNEL=stack
88

99
DB_CONNECTION=mysql
10-
DB_HOST=127.0.0.1
10+
DB_HOST=mysql
1111
DB_PORT=3306
12-
DB_DATABASE=homestead
13-
DB_USERNAME=homestead
12+
DB_DATABASE=messy
13+
DB_USERNAME=user
1414
DB_PASSWORD=secret
1515

1616
BROADCAST_DRIVER=log

public/track.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
require '../vendor/autoload.php';
4+
$dotenv = Dotenv\Dotenv::create('../');
5+
$dotenv->load();
6+
7+
$vote_method = isset($_GET['vote_method']) ? $_GET['vote_method'] : 'up';
8+
9+
10+
$host = getenv('DB_HOST');
11+
$db = getenv('DB_DATABASE');
12+
$user = getenv('DB_USERNAME');
13+
$pass = getenv('DB_PASSWORD');
14+
15+
$dsn = "mysql:host=$host;dbname=$db";
16+
$options = [
17+
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
18+
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
19+
PDO::ATTR_EMULATE_PREPARES => false,
20+
];
21+
try {
22+
$pdo = new PDO($dsn, $user, $pass, $options);
23+
} catch (\PDOException $e) {
24+
throw new \PDOException($e->getMessage(), (int)$e->getCode());
25+
}

0 commit comments

Comments
 (0)