Mass update

This commit is contained in:
2022-12-30 21:03:37 +02:00
parent 7a5dfd22a7
commit e9ec7eb2f2
172 changed files with 14838 additions and 35914 deletions
+26 -16
View File
@@ -1,34 +1,44 @@
<?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;
private static self $instance;
protected static PDO $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));
/**
* Singleton.
*/
private function __construct() {
mysql_select_db(Config::get('db_name'), mysql_connect('localhost', Config::get('db_user'), Config::get('db_password')));
mysql_query('SET NAMES cp1251');
return self::pdoinit();
}
/**
* Для совместимости со старыми функциями mysql_*.
* @return Database
*/
public static function init(): Database
{
if (!isset(self::$instance)) {
self::$instance = new static();
}
return self::$instance;
}
/**
* Новое подключение к БД.
* @return PDO
*/
public static function pdoinit(): PDO
{
return new PDO(
self::DSN,
self::USER,
self::PASSWORD,
'mysql:host=localhost;dbname=' . Config::get('db_name'),
Config::get('db_user'),
Config::get('db_password'),
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,