session_start();
header("Connect-type;text/html;charset=utf-8");
$ini_fields=parse_ini_file("config.ini",true);
define("DB_HOST",$ini_fields["database"]["db_host"],true);
define("DB_NAME",$ini_fields["database"]["db_name"],true);
define("DB_USER",$ini_fields["database"]["db_users"],true);
define("DB_PASW",$ini_fields["database"]["db_password"],true);
require_once "classes/vscar.php";
$db = new vscar(DB_USER, DB_PASW, DB_HOST, DB_NAME);
class vscar
{
public $dbs;
function __construct($user, $pass, $host, $db)
{
$opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_BOTH,
PDO::ATTR_EMULATE_PREPARES => false
];
$charset = "utf8";
$dsn = "mysql:host=$host;dbname=$db;charset=$charset;";
try {
$this -> dbs = new PDO($dsn,$user,$pass,$opt);
$GLOBALS["error"] = "Связь установлена";
}catch (Exception $e){
$GLOBALS["error"] = "Связь не установлена";
}
}
}