Подключение к БД

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
class DB
{
private static $_instance;
public static function __callStatic($name, $arguments)
{
if (!self::$_instance) {
self::$_instance = new PDO('mysql:host=127.0.0.1;dbname=other', 'root', '');
self::$_instance->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
self::$_instance->query('SET NAMES `utf8`');
}
return call_user_func_array([self::$_instance, $name], $arguments);
}
}