@@ 22-44 (lines=23) @@ | ||
19 | * |
|
20 | * @package OCA\Ocr\Db |
|
21 | */ |
|
22 | class FileMapper extends Mapper { |
|
23 | ||
24 | /** |
|
25 | * FileMapper constructor. |
|
26 | * ATTENTION: the common methods like 'delete' 'update' and things like that will not work because we join and cleanup some columns!!! |
|
27 | * |
|
28 | * @param IDBConnection $db |
|
29 | */ |
|
30 | public function __construct(IDBConnection $db) { |
|
31 | parent::__construct($db, 'filecache', 'OCA\Ocr\Db\File'); |
|
32 | } |
|
33 | ||
34 | /** |
|
35 | * Find a specific file entity |
|
36 | * |
|
37 | * @param $fileid |
|
38 | * @return File |
|
39 | */ |
|
40 | public function find($fileid) { |
|
41 | $sql = 'SELECT f.fileid AS fileid, f.path AS path, f.name as name, m.mimetype AS mimetype, s.id AS storagename FROM *PREFIX*filecache AS f, *PREFIX*mimetypes AS m, *PREFIX*storages AS s WHERE f.fileid = ? AND f.mimetype = m.id AND f.storage = s.numeric_id'; |
|
42 | return $this->findEntity($sql, [$fileid]); |
|
43 | } |
|
44 | } |
@@ 22-44 (lines=23) @@ | ||
19 | * |
|
20 | * @package OCA\Ocr\Db |
|
21 | */ |
|
22 | class ShareMapper extends Mapper { |
|
23 | /** |
|
24 | * ShareMapper constructor. |
|
25 | * |
|
26 | * @param IDBConnection $db |
|
27 | */ |
|
28 | public function __construct(IDBConnection $db) { |
|
29 | parent::__construct($db, 'share', 'OCA\Ocr\Db\Share'); |
|
30 | } |
|
31 | ||
32 | /** |
|
33 | * Find the right name for a shared file |
|
34 | * |
|
35 | * @param integer $fileid |
|
36 | * @param string $shareWith |
|
37 | * @param string $owner |
|
38 | * @return Share |
|
39 | */ |
|
40 | public function find($fileid, $shareWith, $owner) { |
|
41 | $sql = 'SELECT file_target FROM *PREFIX*share WHERE file_source = ? AND share_with = ? AND uid_owner = ?'; |
|
42 | return $this->findEntity($sql, [$fileid, $shareWith, $owner]); |
|
43 | } |
|
44 | } |