move connections to the bootstrap

This commit is contained in:
ghost 2023-09-14 20:38:42 +03:00
parent 4135e70b62
commit bf759f9dd7
13 changed files with 25 additions and 151 deletions

View File

@ -41,4 +41,28 @@ require_once __DIR__ . '/../library/scrapeer.php';
require_once __DIR__ . '/../library/time.php'; require_once __DIR__ . '/../library/time.php';
// Vendors autoload // Vendors autoload
require_once __DIR__ . '/../../vendor/autoload.php'; require_once __DIR__ . '/../../vendor/autoload.php';
// Connect database
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch (Exception $e) {
var_dump($e);
exit;
}
// Connect Sphinx
try {
$sphinx = new Sphinx(SPHINX_HOST, SPHINX_PORT);
} catch(Exception $e) {
var_dump($e);
exit;
}

View File

@ -29,9 +29,6 @@ $public = [
// Begin export // Begin export
try try
{ {
// Connect DB
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
// Init API folder if not exists // Init API folder if not exists
@mkdir(__DIR__ . '/../public/api'); @mkdir(__DIR__ . '/../public/api');

View File

@ -28,9 +28,6 @@ $debug =
// Begin export // Begin export
try try
{ {
// Connect DB
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
// Transaction begin // Transaction begin
$db->beginTransaction(); $db->beginTransaction();

View File

@ -19,18 +19,6 @@ $debug = [
], ],
]; ];
// Connect DB
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch(Exception $e) {
var_dump($e);
exit;
}
// Init Scraper // Init Scraper
try { try {

View File

@ -19,18 +19,6 @@ $debug = [
], ],
]; ];
// Connect DB
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch(Exception $e) {
var_dump($e);
exit;
}
// Begin // Begin
try { try {

View File

@ -3,18 +3,6 @@
// Bootstrap // Bootstrap
require_once __DIR__ . '/../config/bootstrap.php'; require_once __DIR__ . '/../config/bootstrap.php';
// Connect database
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch (Exception $e) {
var_dump($e);
exit;
}
// Define response // Define response
$response = (object) $response = (object)
[ [

View File

@ -3,18 +3,6 @@
// Bootstrap // Bootstrap
require_once __DIR__ . '/../config/bootstrap.php'; require_once __DIR__ . '/../config/bootstrap.php';
// Connect database
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch (Exception $e) {
var_dump($e);
exit;
}
// Define response // Define response
$response = (object) $response = (object)
[ [

View File

@ -3,18 +3,6 @@
// Bootstrap // Bootstrap
require_once __DIR__ . '/../config/bootstrap.php'; require_once __DIR__ . '/../config/bootstrap.php';
// Connect database
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch (Exception $e) {
var_dump($e);
exit;
}
// Define variables // Define variables
$response = (object) $response = (object)
[ [

View File

@ -4,18 +4,6 @@
// Bootstrap // Bootstrap
require_once __DIR__ . '/../config/bootstrap.php'; require_once __DIR__ . '/../config/bootstrap.php';
// Connect database
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch (Exception $e) {
var_dump($e);
exit;
}
// Define response // Define response
$response = (object) $response = (object)
[ [

View File

@ -3,30 +3,6 @@
// Bootstrap dependencies // Bootstrap dependencies
require_once __DIR__ . '/../config/bootstrap.php'; require_once __DIR__ . '/../config/bootstrap.php';
// Connect Sphinx
try {
$sphinx = new Sphinx(SPHINX_HOST, SPHINX_PORT);
} catch(Exception $e) {
var_dump($e);
exit;
}
// Connect database
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch (Exception $e) {
var_dump($e);
exit;
}
// Define variables // Define variables
$request = (object) $request = (object)
[ [

View File

@ -3,30 +3,6 @@
// Bootstrap // Bootstrap
require_once __DIR__ . '/../config/bootstrap.php'; require_once __DIR__ . '/../config/bootstrap.php';
// Connect Sphinx
try {
$sphinx = new Sphinx(SPHINX_HOST, SPHINX_PORT);
} catch(Exception $e) {
var_dump($e);
exit;
}
// Connect database
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch (Exception $e) {
var_dump($e);
exit;
}
// Define response // Define response
$response = (object) $response = (object)
[ [

View File

@ -4,18 +4,6 @@
// Bootstrap // Bootstrap
require_once __DIR__ . '/../config/bootstrap.php'; require_once __DIR__ . '/../config/bootstrap.php';
// Connect database
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch (Exception $e) {
var_dump($e);
exit;
}
// Define response // Define response
$response = (object) $response = (object)
[ [

View File

@ -4,18 +4,6 @@
// Bootstrap // Bootstrap
require_once __DIR__ . '/../config/bootstrap.php'; require_once __DIR__ . '/../config/bootstrap.php';
// Connect database
try {
$db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
} catch (Exception $e) {
var_dump($e);
exit;
}
// Define response // Define response
$response = (object) $response = (object)
[ [