<?php

// Change this to your connection info.
$DATABASE_HOST = 'db';

$DATABASE_USER = getenv('MYSQL_USER');
$DATABASE_PASS = getenv('MYSQL_PASSWORD');
$DATABASE_NAME = 'projects';

// Try and connect using the info above.
$con = new mysqli($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
if ( $con->connect_error ) {
	// If there is an error with the connection, stop the script and display the error.
	die ('Failed to connect to MySQL: ' . $con->connect_error);
}

// Change character set to utf8
mysqli_set_charset($con,"utf8");

function run_query($query) {
	global $con;

	return $con->query($query);
}

function get_insert_id() {
	global $con;

	return $con->insert_id;
}

?>