forked from mtierltd/timetracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimelineMapper.php
More file actions
66 lines (49 loc) · 1.75 KB
/
TimelineMapper.php
File metadata and controls
66 lines (49 loc) · 1.75 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
58
59
60
61
62
63
64
65
66
<?php
// db/authormapper.php
namespace OCA\TimeTracker\Db;
use OCP\IDBConnection;
use OCP\AppFramework\Db\Mapper;
class TimelineMapper extends Mapper {
public function __construct(IDBConnection $db) {
parent::__construct($db, 'timetracker_timeline');
}
/**
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
*/
public function find($id) {
$sql = 'SELECT * FROM `*PREFIX*timetracker_timeline` ' .
'WHERE `id` = ?';
return $this->findEntity($sql, [$id]);
}
public function findAll($uid) {
$sql = 'SELECT * FROM `*PREFIX*timetracker_timeline` ' .
'WHERE `user_uid` = ?';
try {
$e = $this->findEntities($sql, [$uid]);
return $e;
} catch (\OCP\AppFramework\Db\DoesNotExistException $e){
return null;
}
}
public function findLatest() {
$sql = 'SELECT * FROM `*PREFIX*timetracker_timeline` ' .
'order by created_at desc limit 100';
try {
$e = $this->findEntities($sql, []);
return $e;
} catch (\OCP\AppFramework\Db\DoesNotExistException $e){
return null;
}
}
public function findByStatus($status) {
$sql = 'SELECT * FROM `*PREFIX*timetracker_timeline` ' .
'WHERE `status` = ?';
try {
$e = $this->findEntities($sql, [$status]);
return $e;
} catch (\OCP\AppFramework\Db\DoesNotExistException $e){
return null;
}
}
}