Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
Michał Sieciechowicz | 248006a830 |
|
@ -7,4 +7,5 @@ use Fufle\ORM\Database\Credentials;
|
||||||
interface IConnector {
|
interface IConnector {
|
||||||
public function getConnectionString(Credentials $credentials);
|
public function getConnectionString(Credentials $credentials);
|
||||||
public function driverEquals(string $driver);
|
public function driverEquals(string $driver);
|
||||||
|
public static function Connect(string $host, int $port, string $database, string $user, string $password);
|
||||||
}
|
}
|
|
@ -3,6 +3,7 @@
|
||||||
namespace Fufle\ORM\Database\Connectors;
|
namespace Fufle\ORM\Database\Connectors;
|
||||||
|
|
||||||
use Fufle\ORM\Database\Credentials;
|
use Fufle\ORM\Database\Credentials;
|
||||||
|
use Fufle\ORM\Database\ConnectionManager;
|
||||||
|
|
||||||
class PostgresConnector implements IConnector {
|
class PostgresConnector implements IConnector {
|
||||||
public function getConnectionString(Credentials $c) {
|
public function getConnectionString(Credentials $c) {
|
||||||
|
@ -11,4 +12,9 @@ class PostgresConnector implements IConnector {
|
||||||
public function driverEquals(string $driver) {
|
public function driverEquals(string $driver) {
|
||||||
return $driver === 'pgsql';
|
return $driver === 'pgsql';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function Connect(string $host, int $port, string $database, string $user, string $password) {
|
||||||
|
ConnectionManager::RegisterConnector(new PostgresConnector());
|
||||||
|
ConnectionManager::Connect('pgsql', $host, $port, $database, $user, $password);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -2,20 +2,21 @@
|
||||||
require_once __DIR__ . '/../vendor/autoload.php';
|
require_once __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
use Fufle\Demo\Model\Job;
|
use Fufle\Demo\Model\Job;
|
||||||
use Fufle\ORM\Database\ConnectionManager;
|
//use Fufle\ORM\Database\ConnectionManager;
|
||||||
use Fufle\ORM\Database\Connectors\PostgresConnector;
|
use Fufle\ORM\Database\Connectors\PostgresConnector;
|
||||||
|
|
||||||
//$dns = 'pgsql:host=localhost;port=5432;dbname=dynamic;user=dynamic;password=password123';
|
//$dns = 'pgsql:host=localhost;port=5432;dbname=dynamic;user=dynamic;password=password123';
|
||||||
$params = [
|
$params = [
|
||||||
'pgsql',
|
// 'pgsql',
|
||||||
'localhost',
|
'localhost',
|
||||||
5432,
|
5432,
|
||||||
'dynamic_dev',
|
'dynamic_dev',
|
||||||
'dynamic',
|
'dynamic',
|
||||||
'Pass@Dyna21',
|
'Pass@Dyna21',
|
||||||
];
|
];
|
||||||
ConnectionManager::RegisterConnector(new PostgresConnector());
|
PostgresConnector::Connect(...$params);
|
||||||
ConnectionManager::Connect(...$params);
|
//ConnectionManager::RegisterConnector(new PostgresConnector());
|
||||||
|
//ConnectionManager::Connect(...$params);
|
||||||
echo "
|
echo "
|
||||||
|
|
||||||
";
|
";
|
||||||
|
|
Loading…
Reference in New Issue