forked from mtierltd/timetracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserToClientMapper.php
More file actions
57 lines (40 loc) · 1.46 KB
/
UserToClientMapper.php
File metadata and controls
57 lines (40 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
// db/authormapper.php
namespace OCA\TimeTracker\Db;
use OCP\IDBConnection;
use OCP\AppFramework\Db\Mapper;
class UserToClientMapper extends Mapper {
public function __construct(IDBConnection $db) {
parent::__construct($db, 'timetracker_user_to_client');
}
public function find($id) {
$sql = 'SELECT * FROM `*PREFIX*timetracker_user_to_client` ' .
'WHERE `id` = ?';
try {
$e = $this->findEntity($sql, [$id]);
return $e;
} catch (\OCP\AppFramework\Db\DoesNotExistException $e){
return null;
}
}
public function findAllForUser($uid) {
$sql = 'SELECT * FROM `*PREFIX*timetracker_user_to_client` ' .
'WHERE `user_uid` = ?';
try {
$e = $this->findEntities($sql, [$uid]);
return $e;
} catch (\OCP\AppFramework\Db\DoesNotExistException $e){
return null;
}
}
public function findForUserAndClient($uid, $client) {
$sql = 'SELECT * FROM `*PREFIX*timetracker_user_to_client` ' .
'WHERE `user_uid` = ? and client_id = ?';
try {
$e = $this->findEntity($sql, [$uid, $client->id]);
return $e;
} catch (\OCP\AppFramework\Db\DoesNotExistException $e){
return null;
}
}
}