Source
This commit is contained in:
25
src/MySQLRequirements.php
Normal file
25
src/MySQLRequirements.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
namespace Aldarien\Models;
|
||||||
|
|
||||||
|
use Aldarien\Common\Definition\DatabaseEngineRequirements as EngineRequirementsInterface;
|
||||||
|
|
||||||
|
class MySQLRequirements implements EngineRequirementsInterface {
|
||||||
|
public function dsnSpecs(): array {
|
||||||
|
return [
|
||||||
|
'host_name',
|
||||||
|
'host_port',
|
||||||
|
'database_name'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
public function getDSN(object $config): string {
|
||||||
|
$dsn = 'mysql:host=' . $config->host->name;
|
||||||
|
if (isset($config->host->port)) {
|
||||||
|
$dsn .= ';port=' . $config->host->port;
|
||||||
|
}
|
||||||
|
$dsn .= '; dbname=' . $config->database->name;
|
||||||
|
return $dsn;
|
||||||
|
}
|
||||||
|
public function hasUser(): bool {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user