Upgrade to some new nextcloud standards

This commit is contained in:
Matias De lellis
2020-05-30 18:33:01 -03:00
parent d417902d94
commit f7ab295a6c
21 changed files with 192 additions and 207 deletions

38
lib/Db/NoteTagMapper.php Normal file
View File

@@ -0,0 +1,38 @@
<?php
namespace OCA\QuickNotes\Db;
use OCP\IDBConnection;
use OCP\AppFramework\Db\Mapper;
class NoteTagMapper extends Mapper {
public function __construct(IDBConnection $db) {
parent::__construct($db, 'quicknotes_note_tags', '\OCA\QuickNotes\Db\NoteTag');
}
public function find($id, $userId) {
$sql = 'SELECT * FROM *PREFIX*quicknotes_note_tags WHERE id = ? AND user_id = ?';
return $this->findEntity($sql, [$id, $userId]);
}
public function findAll($userId) {
$sql = 'SELECT * FROM *PREFIX*quicknotes_note_tags WHERE user_id = ?';
return $this->findEntities($sql, [$userId]);
}
public function findNoteTag($userId, $noteId, $tagId) {
$sql = 'SELECT * FROM *PREFIX*quicknotes_note_tags WHERE user_id = ? AND note_id = ? AND tag_id = ?';
return $this->findEntity($sql, [$userId, $noteId, $tagId]);
}
public function noteTagExists($userId, $noteId, $tagId) {
$sql = 'SELECT * FROM *PREFIX*quicknotes_note_tags WHERE user_id = ? AND note_id = ? AND tag_id = ?';
try {
return $this->findEntities($sql, [$userId, $noteId, $tagId]);
} catch (DoesNotExistException $e) {
return false;
}
return true;
}
}