]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blame - plugins/sql_auth/SQL/sql.php
Add the start of the SQL_Auth plugin
[irc/unrealircd/unrealircd-webpanel.git] / plugins / sql_auth / SQL / sql.php
CommitLineData
ea27475b
VP
1<?php
2
3function sqlnew()
4{
5 $host = SQL_IP;
6 $user = SQL_USERNAME;
7 $pass = SQL_PASSWORD;
8 $db = SQL_DATABASE;
9 $charset = 'utf8mb4';
10
11 $dsn = "mysql:host=$host;dbname=$db;charset=$charset";
12 $options = [
13 PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
14 PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
15 PDO::ATTR_EMULATE_PREPARES => false,
16 ];
17 try {
18 $pdo = new PDO($dsn, $user, $pass, $options);
19 } catch (\PDOException $e) {
20 throw new \PDOException($e->getMessage(), (int)$e->getCode());
21 }
22 return $pdo;
23}