Skip to content

Commit 18a8887

Browse files
author
esmaeel
committed
Add db_config.php for init database connection
1 parent 10da762 commit 18a8887

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

example/db_config.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
use Dotenv\Dotenv;
4+
use React\EventLoop\Loop;
5+
use Saraf\QB\QueryBuilder\Core\DBFactory;
6+
use Saraf\QB\QueryBuilder\Facades\Database;
7+
8+
$loop = Loop::get();
9+
10+
// Environments
11+
$env = Dotenv::createImmutable(__DIR__ . "/../");
12+
$env->load();
13+
14+
// Env Loader
15+
$DB_NAME = $_ENV['DB_NAME'];
16+
$DB_USER = $_ENV['DB_USER'];
17+
$DB_PASS = $_ENV['DB_PASS'];
18+
$DB_HOST = $_ENV['DB_HOST'];
19+
$DB_PORT_READ = $_ENV['DB_PORT_READ'];
20+
$DB_PORT_WRITE = $_ENV['DB_PORT_WRITE'];
21+
22+
23+
24+
Database::initConnection(
25+
new DBFactory(
26+
$loop,
27+
$DB_HOST,
28+
$DB_NAME,
29+
$DB_USER,
30+
$DB_PASS,
31+
$DB_PORT_WRITE,
32+
$DB_PORT_READ,
33+
5,
34+
5,
35+
2,
36+
2
37+
)
38+
);

0 commit comments

Comments
 (0)