Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
5014cca5be | |||
58df21c54f | |||
1bd3ccb8db | |||
99344fda7d | |||
fb37211f7d | |||
a326904825 | |||
816d8f7b9c | |||
2c6c0e6e55 | |||
b964bd65fe | |||
cc7cd638e3 | |||
ac9b141928 | |||
758ff0e282 | |||
d5fde83afb | |||
6dda8e1515 | |||
9ec9fdd731 |
37
Readme.md
37
Readme.md
@ -21,14 +21,14 @@ Database Abstraction Layer
|
||||
...
|
||||
{
|
||||
"type": "git",
|
||||
"path": "https://git.provm.cl/ProVM/database.git"
|
||||
"url": "https://git.provm.cl/ProVM/database.git"
|
||||
}
|
||||
...
|
||||
],
|
||||
...
|
||||
"require": {
|
||||
...
|
||||
"provm/database": "^2.0"
|
||||
"provm/database": "^2.3"
|
||||
...
|
||||
},
|
||||
...
|
||||
@ -41,13 +41,13 @@ For `MySQL`/`MariaDB`
|
||||
|
||||
Without `DI`
|
||||
```
|
||||
$database new MySQL();
|
||||
$database new ProVM\Database\MySQL();
|
||||
$database->setHost(<host>);
|
||||
$database->setPort(<port>); // If diferent from 3306
|
||||
$database->setUsername(<username>);
|
||||
$database->setPassword(<password>);
|
||||
|
||||
$connection = new Connection($database);
|
||||
$connection = new ProVM\Database\Connection($database);
|
||||
```
|
||||
With `DI`
|
||||
```
|
||||
@ -76,8 +76,20 @@ $rs = $connection->execute(<query>, <values>);
|
||||
```
|
||||
Get data from ResultSet
|
||||
```
|
||||
$data = $rs->getAsArray();
|
||||
$data_objs = $rs->getAsObject();
|
||||
$data = $rs->fetchFirst();
|
||||
$data_object = $rs->fetchFirstAsObject();
|
||||
$data_array = $rs->fetchAll();
|
||||
$data_array_of_objects = $rs->fetchAllAsObjects();
|
||||
```
|
||||
Use transactions
|
||||
```
|
||||
$connection->transaction()->begin();
|
||||
try {
|
||||
$connection->execute($query, $values);
|
||||
$connection->transaction()->commit();
|
||||
} catch (PDOException $exception) {
|
||||
$connection->transaction()->rollBack();
|
||||
}
|
||||
```
|
||||
|
||||
## Definitions
|
||||
@ -97,23 +109,20 @@ Connection handling
|
||||
+ `Connection::query` Query the database
|
||||
+ `Connection::prepare` Prepare query statement
|
||||
+ `Connection::execute` Prepare and execute a query statement
|
||||
+ `Conneciton::transaction` Return a transaction
|
||||
+ `Connection::transaction` Return a transaction
|
||||
|
||||
### Transaction
|
||||
Transaction
|
||||
+ `Transaction::begin` Begin transaction
|
||||
+ `Transaction::commit` Commit changes
|
||||
+ `Transaction::rollBack` Roll back changes
|
||||
+ `Transaction::query` Same as `Connection::query`
|
||||
+ `Transaction::prepare` Same as `Connection::prepare`
|
||||
+ `Transaction::execute` Same as `Connection::execute`
|
||||
|
||||
### ResultSet
|
||||
Result set to handle PDOStatement
|
||||
+ `ResultSet::execute` Execute a prepared statement
|
||||
+ `ResultSet::getAsArray` Return query results as array of associative arrays
|
||||
+ `ResultSet::getAsObject` Return query results as array of objects
|
||||
+ `ResultSet::getFirst` Return first result as object
|
||||
+ `ResultSet::fetchAll` Return query results as array of associative arrays
|
||||
+ `ResultSet::fetchAllAsObjects` Return query results as array of objects
|
||||
+ `ResultSet::fetchFirst` Return first result as associative array
|
||||
+ `ResultSet::fetchFirstAsObject` Return first result as object
|
||||
|
||||
## TODO
|
||||
+ Implement other database types. eg: PostgreSQL, SQLite
|
||||
|
@ -1,18 +1,23 @@
|
||||
{
|
||||
"name": "provm/database",
|
||||
"type": "project",
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"kint-php/kint": "^4.2"
|
||||
},
|
||||
"type": "library",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Aldarien",
|
||||
"email": "aldarien85@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {},
|
||||
"require": {
|
||||
"php": ">=8",
|
||||
"ext-pdo": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^10.0",
|
||||
"kint-php/kint": "^5.0"
|
||||
},
|
||||
"autoload": {
|
||||
"ProVM\\": "src/"
|
||||
"psr-4": {
|
||||
"ProVM\\": "src/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,58 +0,0 @@
|
||||
<?php
|
||||
namespace ProVM\Alias;
|
||||
|
||||
use ProVM\Concept\Database as DatabaseInterface;
|
||||
|
||||
abstract class Database implements DatabaseInterface
|
||||
{
|
||||
protected string $host;
|
||||
public function setHost(string $host): DatabaseInterface
|
||||
{
|
||||
$this->host = $host;
|
||||
return $this;
|
||||
}
|
||||
public function getHost(): string
|
||||
{
|
||||
return $this->host;
|
||||
}
|
||||
protected int $port;
|
||||
public function setPort(int $port): DatabaseInterface
|
||||
{
|
||||
$this->port = $port;
|
||||
return $this;
|
||||
}
|
||||
public function getPort(): int
|
||||
{
|
||||
return $this->port;
|
||||
}
|
||||
protected string $name;
|
||||
public function setName(string $name): DatabaseInterface
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
protected string $username;
|
||||
public function setUsername(string $username): DatabaseInterface
|
||||
{
|
||||
$this->username = $username;
|
||||
return $this;
|
||||
}
|
||||
public function getUsername(): string
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
protected string $password;
|
||||
public function setPassword(string $password): DatabaseInterface
|
||||
{
|
||||
$this->password = $password;
|
||||
return $this;
|
||||
}
|
||||
public function getPassword(): string
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
}
|
@ -1,20 +1,18 @@
|
||||
<?php
|
||||
namespace ProVM\Concept;
|
||||
|
||||
use PDO;
|
||||
|
||||
interface Database
|
||||
{
|
||||
public function setHost(string $host): Database;
|
||||
public function getHost(): string;
|
||||
public function setPort(int $port): Database;
|
||||
public function getPort(): int;
|
||||
public function setName(string $name): Database;
|
||||
public function getPort(): int|bool;
|
||||
public function getName(): string;
|
||||
public function setUsername(string $username): Database;
|
||||
public function getUsername(): string;
|
||||
public function setPassword(string $password): Database;
|
||||
public function getUser(): string;
|
||||
public function getPassword(): string;
|
||||
public function needsUser(): bool;
|
||||
public function getDSN(): string;
|
||||
public function setHost(string $host): Database;
|
||||
public function setPort(int $port): Database;
|
||||
public function setName(string $name): Database;
|
||||
public function setUser(string $username): Database;
|
||||
public function setPassword(string $password): Database;
|
||||
public function getDsn(): string;
|
||||
}
|
||||
|
@ -1,18 +1,15 @@
|
||||
<?php
|
||||
namespace ProVM\Concept\Database;
|
||||
|
||||
use PDO;
|
||||
use ProVM\Concept\Database;
|
||||
|
||||
interface Connection
|
||||
{
|
||||
public function setDatabase(Database $database): Connection;
|
||||
public function getDatabase(): Database;
|
||||
public function connect(): Connection;
|
||||
public function setPDO(PDO $pdo): Connection;
|
||||
public function getPDO(): PDO;
|
||||
public function connect(): \PDO;
|
||||
|
||||
public function transaction(): Transaction;
|
||||
|
||||
public function query(string $query): ResultSet;
|
||||
public function prepare(string $query): ResultSet;
|
||||
public function execute(string $query, array $values): ResultSet;
|
||||
public function transaction(): Transaction;
|
||||
public function execute(string $query, ?array $data = null): ResultSet;
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
<?php
|
||||
namespace ProVM\Concept\Database;
|
||||
|
||||
use PDOStatement;
|
||||
|
||||
interface ResultSet
|
||||
{
|
||||
public function __construct(PDOStatement $statement);
|
||||
public function execute(array $values): ResultSet;
|
||||
public function getAsArray(): array;
|
||||
public function getAsObject(): array;
|
||||
public function getFirst(): mixed;
|
||||
public function execute(array $data): ResultSet;
|
||||
|
||||
public function fetchFirst(): array;
|
||||
public function fetchAll(): array;
|
||||
public function fetchFirstAsObject(): object;
|
||||
public function fetchAllAsObjects(): array;
|
||||
}
|
||||
|
@ -4,9 +4,6 @@ namespace ProVM\Concept\Database;
|
||||
interface Transaction
|
||||
{
|
||||
public function begin(): Transaction;
|
||||
public function query(string $query): ResultSet;
|
||||
public function prepare(string $query): ResultSet;
|
||||
public function execute(string $query, array $values): ResultSet;
|
||||
public function commit(): void;
|
||||
public function rollBack(): void;
|
||||
}
|
||||
|
@ -2,74 +2,67 @@
|
||||
namespace ProVM\Database;
|
||||
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use ProVM\Concept\Database;
|
||||
use ProVM\Concept\Database\Connection as ConnectionInterface;
|
||||
use ProVM\Concept\Database\ResultSet as ResultSetInterface;
|
||||
use ProVM\Concept\Database\Transaction as TransactionInterface;
|
||||
|
||||
class Connection implements ConnectionInterface
|
||||
class Connection implements Database\Connection
|
||||
{
|
||||
public function __construct(Database $database)
|
||||
{
|
||||
$this->setDatabase($database);
|
||||
$this->connect();
|
||||
}
|
||||
|
||||
protected Database $database;
|
||||
public function setDatabase(Database $database): ConnectionInterface
|
||||
|
||||
protected function getDatabase(): Database
|
||||
{
|
||||
return $this->database;
|
||||
}
|
||||
|
||||
protected function setDatabase(Database $database): Database\Connection
|
||||
{
|
||||
$this->database = $database;
|
||||
return $this;
|
||||
}
|
||||
public function getDatabase(): Database
|
||||
{
|
||||
return $this->database;
|
||||
}
|
||||
public function connect(): ConnectionInterface
|
||||
|
||||
protected PDO $pdo;
|
||||
public function connect(): PDO
|
||||
{
|
||||
if (!isset($this->pdo)) {
|
||||
$dsn = $this->getDatabase()->getDsn();
|
||||
if ($this->getDatabase()->needsUser()) {
|
||||
$pdo = new PDO($this->getDatabase()->getDSN(), $this->getDatabase()->getUsername(), $this->getDatabase()->getPassword());
|
||||
$this->pdo = new PDO($dsn, $this->getDatabase()->getUser(), $this->getDatabase()->getPassword());
|
||||
} else {
|
||||
$pdo = new PDO($this->getDatabase()->getDSN());
|
||||
$this->pdo = new PDO($dsn);
|
||||
}
|
||||
$this->setPDO($pdo);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
protected PDO $pdo;
|
||||
public function setPDO(PDO $pdo): ConnectionInterface
|
||||
{
|
||||
$this->pdo = $pdo;
|
||||
return $this;
|
||||
}
|
||||
public function getPDO(): PDO
|
||||
{
|
||||
return $this->pdo;
|
||||
}
|
||||
public function query(string $query): ResultSetInterface
|
||||
|
||||
protected Database\Transaction $transaction;
|
||||
|
||||
public function transaction(): Database\Transaction
|
||||
{
|
||||
$st = $this->getPDO()->query($query);
|
||||
if (!$st) {
|
||||
throw new PDOException("Could not run query {$query}");
|
||||
if (!isset($this->transaction)) {
|
||||
$this->transaction = new Transaction($this);
|
||||
}
|
||||
return new ResultSet($st);
|
||||
return $this->transaction;
|
||||
}
|
||||
public function prepare(string $query): ResultSetInterface
|
||||
|
||||
public function query(string $query): Database\ResultSet
|
||||
{
|
||||
$st = $this->getPDO()->prepare($query);
|
||||
if (!$st) {
|
||||
throw new PDOException("Could not prepare query {$query}");
|
||||
return new ResultSet($this->connect()->query($query));
|
||||
}
|
||||
public function prepare(string $query): Database\ResultSet
|
||||
{
|
||||
return new ResultSet($this->connect()->prepare($query));
|
||||
}
|
||||
public function execute(string $query, ?array $data = null): Database\ResultSet
|
||||
{
|
||||
if ($data !== null) {
|
||||
$rs = $this->prepare($query);
|
||||
$rs->execute($data);
|
||||
return $rs;
|
||||
}
|
||||
return new ResultSet($st);
|
||||
}
|
||||
public function execute(string $query, array $values): ResultSetInterface
|
||||
{
|
||||
return $this->prepare($query)->execute($values);
|
||||
}
|
||||
public function transaction(): TransactionInterface
|
||||
{
|
||||
return new Transaction($this->getPDO());
|
||||
return $this->query($query);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace ProVM\Database;
|
||||
|
||||
use ProVM\Alias\Database;
|
||||
use ProVM\Implement\Database;
|
||||
|
||||
class MySQL extends Database
|
||||
{
|
||||
@ -9,20 +9,13 @@ class MySQL extends Database
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDSN(): string
|
||||
public function getDsn(): string
|
||||
{
|
||||
$arr = [
|
||||
"host={$this->getHost()}"
|
||||
];
|
||||
if (isset($this->port)) {
|
||||
$arr []= "port={$this->getPort()}";
|
||||
$dsn = ["mysql:host={$this->getHost()}"];
|
||||
if ($this->getPort()) {
|
||||
$dsn []= "port={$this->getPort()}";
|
||||
}
|
||||
$arr []= "dbname={$this->getName()}";
|
||||
|
||||
return implode(':', [
|
||||
'mysql',
|
||||
implode(';', $arr)
|
||||
]);
|
||||
$dsn []= "dbname={$this->getName()}";
|
||||
return implode(';', $dsn);
|
||||
}
|
||||
}
|
||||
|
19
src/Database/PostgreSQL.php
Normal file
19
src/Database/PostgreSQL.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace ProVM\Database;
|
||||
|
||||
use ProVM\Implement\Database;
|
||||
|
||||
class PostgreSQL extends Database
|
||||
{
|
||||
public function getDsn(): string
|
||||
{
|
||||
$dsn = ["pgsql:host={$this->getHost()}"];
|
||||
if ($this->getPort()) {
|
||||
$dsn []= "port={$this->getPort()}";
|
||||
}
|
||||
$dsn []= "dbname={$this->getName()}";
|
||||
$dsn []= "user={$this->getUser()}";
|
||||
$dsn []= "password={$this->getPassword()}";
|
||||
return implode(';', $dsn);
|
||||
}
|
||||
}
|
@ -3,9 +3,10 @@ namespace ProVM\Database;
|
||||
|
||||
use PDO;
|
||||
use PDOStatement;
|
||||
use ProVM\Concept\Database\ResultSet as RSInterface;
|
||||
use ProVM\Concept\Database;
|
||||
use ProVM\Exception\Database\BlankResult;
|
||||
|
||||
class ResultSet implements RSInterface
|
||||
class ResultSet implements Database\ResultSet
|
||||
{
|
||||
public function __construct(PDOStatement $statement)
|
||||
{
|
||||
@ -13,32 +14,44 @@ class ResultSet implements RSInterface
|
||||
}
|
||||
|
||||
protected PDOStatement $statement;
|
||||
public function setStatement(PDOStatement $statement): RSInterface
|
||||
|
||||
protected function getStatement(): PDOStatement
|
||||
{
|
||||
return $this->statement;
|
||||
}
|
||||
protected function setStatement(PDOStatement $statement): ResultSet
|
||||
{
|
||||
$this->statement = $statement;
|
||||
return $this;
|
||||
}
|
||||
public function getStatement(): PDOStatement
|
||||
{
|
||||
return $this->statement;
|
||||
}
|
||||
|
||||
public function execute(array $values): RSInterface
|
||||
public function execute(array $data): Database\ResultSet
|
||||
{
|
||||
$this->getStatement()->execute($values);
|
||||
$this->statement->execute($data);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAsArray(): array
|
||||
protected function checkResults(): PDOStatement
|
||||
{
|
||||
return $this->getStatement()->fetchAll(PDO::FETCH_ASSOC);
|
||||
if ($this->getStatement()->rowCount() === 0) {
|
||||
throw new BlankResult(query: $this->getStatement()->queryString);
|
||||
}
|
||||
return $this->getStatement();
|
||||
}
|
||||
public function getAsObject(): array
|
||||
public function fetchFirst(): array
|
||||
{
|
||||
return $this->getStatement()->fetchAll(PDO::FETCH_OBJ);
|
||||
return $this->checkResults()->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
public function getFirst(): mixed
|
||||
public function fetchAll(): array
|
||||
{
|
||||
return $this->getStatement()->fetch(PDO::FETCH_OBJ);
|
||||
return $this->checkResults()->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
public function fetchFirstAsObject(): object
|
||||
{
|
||||
return $this->checkResults()->fetch(PDO::FETCH_OBJ);
|
||||
}
|
||||
public function fetchAllAsObjects(): array
|
||||
{
|
||||
return $this->checkResults()->fetchAll(PDO::FETCH_OBJ);
|
||||
}
|
||||
}
|
||||
|
12
src/Database/SQLite.php
Normal file
12
src/Database/SQLite.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace ProVM\Database;
|
||||
|
||||
use ProVM\Implement\Database;
|
||||
|
||||
class SQLite extends Database
|
||||
{
|
||||
public function getDsn(): string
|
||||
{
|
||||
return "sqlite:{$this->getHost()}";
|
||||
}
|
||||
}
|
@ -2,58 +2,39 @@
|
||||
namespace ProVM\Database;
|
||||
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use ProVM\Concept\Database\ResultSet as ResultSetInterface;
|
||||
use ProVM\Concept\Database\Transaction as TransactionInterface;
|
||||
use ProVM\Concept;
|
||||
|
||||
class Transaction implements TransactionInterface
|
||||
class Transaction implements Concept\Database\Transaction
|
||||
{
|
||||
public function __construct(PDO $pdo)
|
||||
public function __construct(Concept\Database\Connection $connection)
|
||||
{
|
||||
$this->setPDO($pdo);
|
||||
$this->setConnection($connection);
|
||||
}
|
||||
|
||||
protected PDO $pdo;
|
||||
public function setPDO(PDO $pdo): TransactionInterface
|
||||
protected Concept\Database\Connection $connection;
|
||||
|
||||
public function getConnection(): Concept\Database\Connection
|
||||
{
|
||||
$this->pdo = $pdo;
|
||||
return $this->connection;
|
||||
}
|
||||
|
||||
public function setConnection(Concept\Database\Connection $connection): Concept\Database\Transaction
|
||||
{
|
||||
$this->connection = $connection;
|
||||
return $this;
|
||||
}
|
||||
public function getPDO(): PDO
|
||||
|
||||
public function begin(): Concept\Database\Transaction
|
||||
{
|
||||
return $this->pdo;
|
||||
}
|
||||
public function begin(): TransactionInterface
|
||||
{
|
||||
$this->getPDO()->beginTransaction();
|
||||
$this->getConnection()->connect()->beginTransaction();
|
||||
return $this;
|
||||
}
|
||||
public function query(string $query): ResultSetInterface
|
||||
{
|
||||
$st = $this->getPDO()->query($query);
|
||||
if (!$st) {
|
||||
throw new PDOException("Could not run query {$query}");
|
||||
}
|
||||
return new ResultSet($st);
|
||||
}
|
||||
public function prepare(string $query): ResultSetInterface
|
||||
{
|
||||
$st = $this->getPDO()->prepare($query);
|
||||
if (!$st) {
|
||||
throw new PDOException("Could not prepare query {$query}");
|
||||
}
|
||||
return new ResultSet($st);
|
||||
}
|
||||
public function execute(string $query, array $values): ResultSetInterface
|
||||
{
|
||||
return $this->prepare($query)->execute($values);
|
||||
}
|
||||
public function commit(): void
|
||||
{
|
||||
$this->getPDO()->commit();
|
||||
$this->getConnection()->connect()->commit();
|
||||
}
|
||||
public function rollBack(): void
|
||||
{
|
||||
$this->getPDO()->rollBack();
|
||||
$this->getConnection()->connect()->rollBack();
|
||||
}
|
||||
}
|
||||
|
16
src/Exception/Database.php
Normal file
16
src/Exception/Database.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace ProVM\Exception;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
abstract class Database extends Exception
|
||||
{
|
||||
const BASE_CODE = 600;
|
||||
|
||||
public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null)
|
||||
{
|
||||
$code += Database::BASE_CODE;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
20
src/Exception/Database/BlankResult.php
Normal file
20
src/Exception/Database/BlankResult.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace ProVM\Exception\Database;
|
||||
|
||||
use Throwable;
|
||||
use ProVM\Exception\Database;
|
||||
|
||||
class BlankResult extends Database
|
||||
{
|
||||
public function __construct(?string $table = null, ?string $query = null, ?Throwable $previous = null)
|
||||
{
|
||||
$message = implode('', [
|
||||
"No results found",
|
||||
($query !== null) ? " in {$query}" : '',
|
||||
($table !== null) ? " in {$table}" : '',
|
||||
'.'
|
||||
]);
|
||||
$code = 1;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
65
src/Implement/Database.php
Normal file
65
src/Implement/Database.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
namespace ProVM\Implement;
|
||||
|
||||
use ProVM\Concept;
|
||||
|
||||
abstract class Database implements Concept\Database
|
||||
{
|
||||
protected string $host;
|
||||
protected int $port;
|
||||
protected string $name;
|
||||
protected string $user;
|
||||
protected string $password;
|
||||
|
||||
public function getHost(): string
|
||||
{
|
||||
return $this->host;
|
||||
}
|
||||
public function getPort(): int|bool
|
||||
{
|
||||
return $this->port ?? false;
|
||||
}
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
public function getUser(): string
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
public function getPassword(): string
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function setHost(string $host): Concept\Database
|
||||
{
|
||||
$this->host = $host;
|
||||
return $this;
|
||||
}
|
||||
public function setPort(int $port): Concept\Database
|
||||
{
|
||||
$this->port = $port;
|
||||
return $this;
|
||||
}
|
||||
public function setName(string $name): Concept\Database
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
public function setUser(string $username): Concept\Database
|
||||
{
|
||||
$this->user = $username;
|
||||
return $this;
|
||||
}
|
||||
public function setPassword(string $password): Concept\Database
|
||||
{
|
||||
$this->password = $password;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function needsUser(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user