Version 3.0
New technologies
This commit is contained in:
27
api/src/Implement/Database/MySQL.php
Normal file
27
api/src/Implement/Database/MySQL.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user