Skip to content

Commit 6b00cc9

Browse files
committed
lazyload pdo wip
1 parent 39562a1 commit 6b00cc9

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

src/Tqdev/PhpCrudApi/Database/GenericDB.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function __construct(string $driver, string $address, int $port, string $
8383
$this->converter = new DataConverter($driver);
8484
}
8585

86-
public function pdo(): \PDO
86+
public function pdo(): LazyPdo
8787
{
8888
return $this->pdo;
8989
}

src/Tqdev/PhpCrudApi/Database/LazyPdo.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,14 @@ private function pdo()
2727
return $this->pdo;
2828
}
2929

30-
public function setUser(/*?string*/ $user): bool
30+
public function reauthenticate(/*?string*/ $user, /*?string*/ $password): bool
3131
{
32-
if ($this->pdo) {
33-
return false;
34-
}
3532
$this->user = $user;
36-
return true;
37-
}
38-
39-
public function setPassword(/*?string*/ $password): bool
40-
{
33+
$this->password = $password;
4134
if ($this->pdo) {
42-
return false;
35+
$this->pdo = new \PDO($this->dsn, $this->user, $this->password, $this->options);
36+
return false;
4337
}
44-
$this->password = $password;
4538
return true;
4639
}
4740

0 commit comments

Comments
 (0)