game/_incl_data/class/Core/Database.php

40 lines
946 B
PHP
Raw Normal View History

2022-12-19 20:22:19 +00:00
<?php
# Let's hope it will work.
namespace Core;
use PDO;
class Database
{
private const DB = 'newcom1_abk';
private const USER = 'newcom1_abk';
private const PASSWORD = '4nWYsIM[c?}P';
private const DSN = 'mysql:host=localhost;dbname=' . self::DB;
//todo: remove PDO from files and connect through new pdoinit().
public static function init(): PDO
{
mysql_select_db(self::DB, mysql_connect('localhost', self::USER, self::PASSWORD));
mysql_query('SET NAMES cp1251');
return self::pdoinit();
}
public static function pdoinit(): PDO
{
return new PDO(
self::DSN,
self::USER,
self::PASSWORD,
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES cp1251",
]
);
}
}