diff options
author | Vinzenz <vinzenz.rosenkranz@gmail.com> | 2016-03-14 14:09:56 +0300 |
---|---|---|
committer | Vinzenz <vinzenz.rosenkranz@gmail.com> | 2016-03-14 14:09:56 +0300 |
commit | 01e88b9524bc7e70018fa9224348172e73167b92 (patch) | |
tree | 733b8a0bb61502927c47d48bb992332e889b664b /db | |
parent | a7d6993eeaff62a03ffebac3990e91f2e5c2e90d (diff) |
get text participations
Diffstat (limited to 'db')
-rw-r--r-- | db/participationtext.php | 21 | ||||
-rw-r--r-- | db/participationtextmapper.php | 84 |
2 files changed, 105 insertions, 0 deletions
diff --git a/db/participationtext.php b/db/participationtext.php new file mode 100644 index 00000000..edc65787 --- /dev/null +++ b/db/participationtext.php @@ -0,0 +1,21 @@ +<?php
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Entity;
+
+/**
+ * @method text getText()
+ * @method void setText(text $value)
+ * @method string getUserId()
+ * @method void setUserId(string $value)
+ * @method integer getPollId()
+ * @method void setPollId(integer $value)
+ * @method integer getType()
+ * @method void setType(integer $value)
+ */
+class ParticipationText extends Entity {
+ public $text;
+ public $userId;
+ public $pollId;
+ public $type;
+}
diff --git a/db/participationtextmapper.php b/db/participationtextmapper.php new file mode 100644 index 00000000..984b8f53 --- /dev/null +++ b/db/participationtextmapper.php @@ -0,0 +1,84 @@ +<?php
+namespace OCA\Polls\Db;
+
+use OCP\AppFramework\Db\Mapper;
+use OCP\IDb;
+
+class ParticipationTextMapper extends Mapper {
+
+ public function __construct(IDB $db) {
+ parent::__construct($db, 'polls_particip_text', '\OCA\Polls\Db\ParticipationText');
+ }
+
+ /**
+ * @param int $id
+ * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
+ * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
+ * @return ParticipationText
+ */
+ public function find($id) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_particip_text` '.
+ 'WHERE `id` = ?';
+ return $this->findEntity($sql, [$id]);
+ }
+
+ public function deleteByPollAndUser($pollId, $userId) {
+ $sql = 'DELETE FROM `*PREFIX*polls_particip_text` WHERE poll_id=? AND user_id=?';
+ $this->execute($sql, [$pollId, $userId]);
+ }
+
+ /**
+ * @param string $userId
+ * @param string $from
+ * @param string $until
+ * @param int $limit
+ * @param int $offset
+ * @return ParticipationText[]
+ */
+ public function findBetween($userId, $from, $until, $limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_particip_text` '.
+ 'WHERE `userId` = ?'.
+ 'AND `timestamp` BETWEEN ? and ?';
+ return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset);
+ }
+
+ /**
+ * @param int $limit
+ * @param int $offset
+ * @return ParticipationText[]
+ */
+ public function findAll($limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_particip_text`';
+ return $this->findEntities($sql, [], $limit, $offset);
+ }
+
+ /**
+ * @param string $userId
+ * @param int $limit
+ * @param int $offset
+ * @return ParticipationText[]
+ */
+ public function findDistinctByUser($userId, $limit=null, $offset=null) {
+ $sql = 'SELECT DISTINCT * FROM `*PREFIX*polls_particip_text` WHERE user_id=?';
+ return $this->findEntities($sql, [$userId], $limit, $offset);
+ }
+
+ /**
+ * @param string $userId
+ * @param int $limit
+ * @param int $offset
+ * @return ParticipationText[]
+ */
+ public function findByPoll($pollId, $limit=null, $offset=null) {
+ $sql = 'SELECT * FROM `*PREFIX*polls_particip_text` WHERE poll_id=?';
+ return $this->findEntities($sql, [$pollId], $limit, $offset);
+ }
+
+ /**
+ * @param string $pollId
+ */
+ public function deleteByPoll($pollId) {
+ $sql = 'DELETE FROM `*PREFIX*polls_particip_text` WHERE poll_id=?';
+ $this->execute($sql, [$pollId], $limit, $offset);
+ }
+}
|