/**
* Create a new connection to the database
*
* @param string $host The MySQL host
* @param string $user The MySQL user
* @param string $password The MySQL password for the user
* @param string $dbName The MySQL database name
*
* @return Database A database object to interact with the database
*/
public function __construct($host, $user, $password, $dbName)
{
if (Service::getContainer()) {
if ($logger = Service::getContainer()->get('monolog.logger.mysql')) {
$this->logger = $logger;
}
}
$this->dbc = new mysqli($host, $user, $password, $dbName);
if ($this->dbc->connect_errno) {
$this->logger->addAlert($this->dbc->connect_error);
throw new Exception($this->dbc->connect_error, $this->dbc->connect_errno);
}
$this->dbc->set_charset("utf8");
}