mirror of
https://github.com/JanGross/quicknotes.git
synced 2025-12-01 07:37:18 +01:00
Put color on own database. Umm.. Any relationship placed on the note controller.
This commit is contained in:
39
db/colormapper.php
Normal file
39
db/colormapper.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace OCA\QuickNotes\Db;
|
||||
|
||||
use OCP\IDb;
|
||||
use OCP\AppFramework\Db\Mapper;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
|
||||
class ColorMapper extends Mapper {
|
||||
|
||||
public function __construct(IDb $db) {
|
||||
parent::__construct($db, 'quicknotes_colors', '\OCA\QuickNotes\Db\Color');
|
||||
}
|
||||
|
||||
public function find($id) {
|
||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_colors WHERE id = ?';
|
||||
return $this->findEntity($sql, [$id]);
|
||||
}
|
||||
|
||||
public function findAll() {
|
||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_colors';
|
||||
return $this->findEntities($sql, []);
|
||||
}
|
||||
|
||||
public function findByColor($color) {
|
||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_colors WHERE color = ?';
|
||||
return $this->findEntity($sql, [$color]);
|
||||
}
|
||||
|
||||
public function colorExists($color) {
|
||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_colors WHERE color = ?';
|
||||
try {
|
||||
$this->findEntity($sql, [$color]);
|
||||
} catch (DoesNotExistException $e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user