Files
contabilidad/api/src/Implement/Database/MySQL.php
Aldarien a9968dec58 Version 3.0
New technologies
2022-08-05 21:28:59 -04:00

28 lines
720 B
PHP

<?php
namespace Contabilidad\Implement\Database;
use Common\Alias\Database;
class MySQL extends Database
{
public function __construct(string $host, string $username, string $password, string $database_name, int $port = 3306)
{
$this->setHost($host, $port);
$this->setUser($username, $password);
$this->setName($database_name);
}
public function getDsn(): string
{
$dsn = ["mysql:host={$this->getHost()}"];
if ($this->getPort() !== 3306) {
$dsn []= "port={$this->getPort()}";
}
$dsn []= "dbname={$this->getName()}";
return implode(';', $dsn);
}
public function needsUser(): bool
{
return true;
}
}