Skip to content

Commit a03bfea

Browse files
committed
refactor to use db class
1 parent 0d1d70c commit a03bfea

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

lib/ClientRegistration.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
<?php
22
namespace Pdsinterop\PhpSolid;
3-
3+
4+
use Pdsinterop\PhpSolid\Db;
5+
46
class ClientRegistration {
5-
private static $pdo;
6-
private static function connect() {
7-
if (!isset(self::$pdo)) {
8-
self::$pdo = new \PDO("sqlite:" . DBPATH);
9-
}
10-
}
11-
127
public static function getRegistration($clientId) {
13-
self::connect();
14-
$query = self::$pdo->prepare(
8+
Db::connect();
9+
$query = Db::$pdo->prepare(
1510
'SELECT clientData FROM clients WHERE clientId=:clientId'
1611
);
1712
$query->execute([
@@ -25,11 +20,11 @@ public static function getRegistration($clientId) {
2520
}
2621

2722
public static function saveClientRegistration($clientData) {
28-
self::connect();
23+
Db::connect();
2924
if (!isset($clientData['client_name'])) {
3025
$clientData['client_name'] = $clientData['origin'];
3126
}
32-
$query = self::$pdo->prepare(
27+
$query = Db::$pdo->prepare(
3328
'INSERT INTO clients VALUES(:clientId, :origin, :clientData)'
3429
);
3530
$query->execute([
@@ -40,8 +35,8 @@ public static function saveClientRegistration($clientData) {
4035
}
4136

4237
public static function getClientByOrigin($origin) {
43-
self::connect();
44-
$query = self::$pdo->prepare(
38+
Db::connect();
39+
$query = Db::$pdo->prepare(
4540
'SELECT clientData FROM clients WHERE origin=:origin'
4641
);
4742
$query->execute([

0 commit comments

Comments
 (0)