14 lines
342 B
PHP
14 lines
342 B
PHP
|
<?php
|
||
|
|
||
|
function connectDatabase($user, $pass, $db) {
|
||
|
$unix_socket = '.mysql/mysql.sock';
|
||
|
$charset = 'utf8mb4';
|
||
|
$dsn = "mysql:unix_socket=$unix_socket;dbname=$db;charset=$charset";
|
||
|
$db_connection = new PDO($dsn, $user, $pass);
|
||
|
return $db_connection;
|
||
|
}
|
||
|
|
||
|
function closeDatabase($db_connection) {
|
||
|
$db_connection = null;
|
||
|
}
|