v0.1.0
This commit is contained in:
25
provm/common/Service/Database/DSN.php
Normal file
25
provm/common/Service/Database/DSN.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace ProVM\Common\Service\Database;
|
||||
|
||||
class DSN {
|
||||
public $engine;
|
||||
public function __construct(string $engine) {
|
||||
$this->engine = $engine;
|
||||
}
|
||||
public $pairs;
|
||||
public function addPair($name, $value) {
|
||||
if ($this->pairs === null) {
|
||||
$this->pairs = [];
|
||||
}
|
||||
$this->pairs []= [$name, $value];
|
||||
return $this;
|
||||
}
|
||||
public function __toString() {
|
||||
return implode(':', [
|
||||
$this->engine,
|
||||
implode(';', array_map(function($item) {
|
||||
return implode('=', $item);
|
||||
}, $this->pairs))
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user