@@ -33,65 +33,65 @@ |
||
| 33 | 33 | |
| 34 | 34 | class ParticipationMapperTest extends UnitTestCase { |
| 35 | 35 | |
| 36 | - /** @var IDBConnection */ |
|
| 37 | - private $con; |
|
| 38 | - /** @var ParticipationMapper */ |
|
| 39 | - private $participationMapper; |
|
| 40 | - /** @var EventMapper */ |
|
| 41 | - private $eventMapper; |
|
| 36 | + /** @var IDBConnection */ |
|
| 37 | + private $con; |
|
| 38 | + /** @var ParticipationMapper */ |
|
| 39 | + private $participationMapper; |
|
| 40 | + /** @var EventMapper */ |
|
| 41 | + private $eventMapper; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * {@inheritDoc} |
|
| 45 | - */ |
|
| 46 | - public function setUp() { |
|
| 47 | - parent::setUp(); |
|
| 48 | - $this->con = \OC::$server->getDatabaseConnection(); |
|
| 49 | - $this->participationMapper = new ParticipationMapper($this->con); |
|
| 50 | - $this->eventMapper = new EventMapper($this->con); |
|
| 51 | - } |
|
| 43 | + /** |
|
| 44 | + * {@inheritDoc} |
|
| 45 | + */ |
|
| 46 | + public function setUp() { |
|
| 47 | + parent::setUp(); |
|
| 48 | + $this->con = \OC::$server->getDatabaseConnection(); |
|
| 49 | + $this->participationMapper = new ParticipationMapper($this->con); |
|
| 50 | + $this->eventMapper = new EventMapper($this->con); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Create some fake data and persist them to the database. |
|
| 55 | - * |
|
| 56 | - * @return Participation |
|
| 57 | - */ |
|
| 58 | - public function testCreate() { |
|
| 59 | - /** @var Event $event */ |
|
| 60 | - $event = $this->fm->instance('OCA\Polls\Db\Event'); |
|
| 61 | - $this->assertInstanceOf(Event::class, $this->eventMapper->insert($event)); |
|
| 53 | + /** |
|
| 54 | + * Create some fake data and persist them to the database. |
|
| 55 | + * |
|
| 56 | + * @return Participation |
|
| 57 | + */ |
|
| 58 | + public function testCreate() { |
|
| 59 | + /** @var Event $event */ |
|
| 60 | + $event = $this->fm->instance('OCA\Polls\Db\Event'); |
|
| 61 | + $this->assertInstanceOf(Event::class, $this->eventMapper->insert($event)); |
|
| 62 | 62 | |
| 63 | - /** @var Participation $participation */ |
|
| 64 | - $participation = $this->fm->instance('OCA\Polls\Db\Participation'); |
|
| 65 | - $participation->setPollId($event->getId()); |
|
| 66 | - $this->assertInstanceOf(Participation::class, $this->participationMapper->insert($participation)); |
|
| 63 | + /** @var Participation $participation */ |
|
| 64 | + $participation = $this->fm->instance('OCA\Polls\Db\Participation'); |
|
| 65 | + $participation->setPollId($event->getId()); |
|
| 66 | + $this->assertInstanceOf(Participation::class, $this->participationMapper->insert($participation)); |
|
| 67 | 67 | |
| 68 | - return $participation; |
|
| 69 | - } |
|
| 68 | + return $participation; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Update the previously created entry and persist the changes. |
|
| 73 | - * |
|
| 74 | - * @depends testCreate |
|
| 75 | - * @param Participation $participation |
|
| 76 | - * @return Participation |
|
| 77 | - */ |
|
| 78 | - public function testUpdate(Participation $participation) { |
|
| 79 | - $newDt = Faker::date('Y-m-d H:i:s'); |
|
| 80 | - $participation->setDt($newDt()); |
|
| 81 | - $this->participationMapper->update($participation); |
|
| 71 | + /** |
|
| 72 | + * Update the previously created entry and persist the changes. |
|
| 73 | + * |
|
| 74 | + * @depends testCreate |
|
| 75 | + * @param Participation $participation |
|
| 76 | + * @return Participation |
|
| 77 | + */ |
|
| 78 | + public function testUpdate(Participation $participation) { |
|
| 79 | + $newDt = Faker::date('Y-m-d H:i:s'); |
|
| 80 | + $participation->setDt($newDt()); |
|
| 81 | + $this->participationMapper->update($participation); |
|
| 82 | 82 | |
| 83 | - return $participation; |
|
| 84 | - } |
|
| 83 | + return $participation; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Delete the previously created entries from the database. |
|
| 88 | - * |
|
| 89 | - * @depends testUpdate |
|
| 90 | - * @param Participation $participation |
|
| 91 | - */ |
|
| 92 | - public function testDelete(Participation $participation) { |
|
| 93 | - $event = $this->eventMapper->find($participation->getPollId()); |
|
| 94 | - $this->participationMapper->delete($participation); |
|
| 95 | - $this->eventMapper->delete($event); |
|
| 96 | - } |
|
| 86 | + /** |
|
| 87 | + * Delete the previously created entries from the database. |
|
| 88 | + * |
|
| 89 | + * @depends testUpdate |
|
| 90 | + * @param Participation $participation |
|
| 91 | + */ |
|
| 92 | + public function testDelete(Participation $participation) { |
|
| 93 | + $event = $this->eventMapper->find($participation->getPollId()); |
|
| 94 | + $this->participationMapper->delete($participation); |
|
| 95 | + $this->eventMapper->delete($event); |
|
| 96 | + } |
|
| 97 | 97 | } |
@@ -31,57 +31,57 @@ |
||
| 31 | 31 | |
| 32 | 32 | class EventMapperTest extends UnitTestCase { |
| 33 | 33 | |
| 34 | - /** @var IDBConnection */ |
|
| 35 | - private $con; |
|
| 36 | - /** @var EventMapper */ |
|
| 37 | - private $eventMapper; |
|
| 34 | + /** @var IDBConnection */ |
|
| 35 | + private $con; |
|
| 36 | + /** @var EventMapper */ |
|
| 37 | + private $eventMapper; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * {@inheritDoc} |
|
| 41 | - */ |
|
| 42 | - public function setUp() { |
|
| 43 | - parent::setUp(); |
|
| 44 | - $this->con = \OC::$server->getDatabaseConnection(); |
|
| 45 | - $this->eventMapper = new EventMapper($this->con); |
|
| 46 | - } |
|
| 39 | + /** |
|
| 40 | + * {@inheritDoc} |
|
| 41 | + */ |
|
| 42 | + public function setUp() { |
|
| 43 | + parent::setUp(); |
|
| 44 | + $this->con = \OC::$server->getDatabaseConnection(); |
|
| 45 | + $this->eventMapper = new EventMapper($this->con); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Create some fake data and persist them to the database. |
|
| 50 | - * |
|
| 51 | - * @return Event |
|
| 52 | - */ |
|
| 53 | - public function testCreate() { |
|
| 54 | - /** @var Event $event */ |
|
| 55 | - $event = $this->fm->instance('OCA\Polls\Db\Event'); |
|
| 56 | - $this->assertInstanceOf(Event::class, $this->eventMapper->insert($event)); |
|
| 48 | + /** |
|
| 49 | + * Create some fake data and persist them to the database. |
|
| 50 | + * |
|
| 51 | + * @return Event |
|
| 52 | + */ |
|
| 53 | + public function testCreate() { |
|
| 54 | + /** @var Event $event */ |
|
| 55 | + $event = $this->fm->instance('OCA\Polls\Db\Event'); |
|
| 56 | + $this->assertInstanceOf(Event::class, $this->eventMapper->insert($event)); |
|
| 57 | 57 | |
| 58 | - return $event; |
|
| 59 | - } |
|
| 58 | + return $event; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Update the previously created entry and persist the changes. |
|
| 63 | - * |
|
| 64 | - * @depends testCreate |
|
| 65 | - * @param Event $event |
|
| 66 | - * @return Event |
|
| 67 | - */ |
|
| 68 | - public function testUpdate(Event $event) { |
|
| 69 | - $newTitle = Faker::sentence(10); |
|
| 70 | - $newDescription = Faker::paragraph(); |
|
| 71 | - $event->setTitle($newTitle()); |
|
| 72 | - $event->setDescription($newDescription()); |
|
| 73 | - $this->eventMapper->update($event); |
|
| 61 | + /** |
|
| 62 | + * Update the previously created entry and persist the changes. |
|
| 63 | + * |
|
| 64 | + * @depends testCreate |
|
| 65 | + * @param Event $event |
|
| 66 | + * @return Event |
|
| 67 | + */ |
|
| 68 | + public function testUpdate(Event $event) { |
|
| 69 | + $newTitle = Faker::sentence(10); |
|
| 70 | + $newDescription = Faker::paragraph(); |
|
| 71 | + $event->setTitle($newTitle()); |
|
| 72 | + $event->setDescription($newDescription()); |
|
| 73 | + $this->eventMapper->update($event); |
|
| 74 | 74 | |
| 75 | - return $event; |
|
| 76 | - } |
|
| 75 | + return $event; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Delete the previously created entry from the database. |
|
| 80 | - * |
|
| 81 | - * @depends testUpdate |
|
| 82 | - * @param Event $event |
|
| 83 | - */ |
|
| 84 | - public function testDelete(Event $event) { |
|
| 85 | - $this->eventMapper->delete($event); |
|
| 86 | - } |
|
| 78 | + /** |
|
| 79 | + * Delete the previously created entry from the database. |
|
| 80 | + * |
|
| 81 | + * @depends testUpdate |
|
| 82 | + * @param Event $event |
|
| 83 | + */ |
|
| 84 | + public function testDelete(Event $event) { |
|
| 85 | + $this->eventMapper->delete($event); |
|
| 86 | + } |
|
| 87 | 87 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | 24 | if (!defined('PHPUNIT_RUN')) { |
| 25 | - define('PHPUNIT_RUN', 1); |
|
| 25 | + define('PHPUNIT_RUN', 1); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | require_once __DIR__ . '/../../../lib/base.php'; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | \OC_App::loadApp('polls'); |
| 33 | 33 | |
| 34 | 34 | if (!class_exists('PHPUnit_Framework_TestCase')) { |
| 35 | - require_once 'PHPUnit/Autoload.php'; |
|
| 35 | + require_once 'PHPUnit/Autoload.php'; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | \OC_Hook::clear(); |
@@ -27,5 +27,5 @@ |
||
| 27 | 27 | * General factory for the notification model. |
| 28 | 28 | */ |
| 29 | 29 | $fm->define('OCA\Polls\Db\Notification')->setDefinitions([ |
| 30 | - 'userId' => Faker::firstNameMale() |
|
| 30 | + 'userId' => Faker::firstNameMale() |
|
| 31 | 31 | ]); |
@@ -28,41 +28,41 @@ |
||
| 28 | 28 | |
| 29 | 29 | class CommentMapper extends Mapper { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * CommentMapper constructor. |
|
| 33 | - * @param IDBConnection $db |
|
| 34 | - */ |
|
| 35 | - public function __construct(IDBConnection $db) { |
|
| 36 | - parent::__construct($db, 'polls_comments', '\OCA\Polls\Db\Comment'); |
|
| 37 | - } |
|
| 31 | + /** |
|
| 32 | + * CommentMapper constructor. |
|
| 33 | + * @param IDBConnection $db |
|
| 34 | + */ |
|
| 35 | + public function __construct(IDBConnection $db) { |
|
| 36 | + parent::__construct($db, 'polls_comments', '\OCA\Polls\Db\Comment'); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @param string $userId |
|
| 41 | - * @param int $limit |
|
| 42 | - * @param int $offset |
|
| 43 | - * @return Comment[] |
|
| 44 | - */ |
|
| 45 | - public function findDistinctByUser($userId, $limit = null, $offset = null) { |
|
| 46 | - $sql = 'SELECT DISTINCT * FROM ' . $this->getTableName() . ' WHERE user_id = ?'; |
|
| 47 | - return $this->findEntities($sql, [$userId], $limit, $offset); |
|
| 48 | - } |
|
| 39 | + /** |
|
| 40 | + * @param string $userId |
|
| 41 | + * @param int $limit |
|
| 42 | + * @param int $offset |
|
| 43 | + * @return Comment[] |
|
| 44 | + */ |
|
| 45 | + public function findDistinctByUser($userId, $limit = null, $offset = null) { |
|
| 46 | + $sql = 'SELECT DISTINCT * FROM ' . $this->getTableName() . ' WHERE user_id = ?'; |
|
| 47 | + return $this->findEntities($sql, [$userId], $limit, $offset); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @param int $pollId |
|
| 52 | - * @param int $limit |
|
| 53 | - * @param int $offset |
|
| 54 | - * @return Comment[] |
|
| 55 | - */ |
|
| 56 | - public function findByPoll($pollId, $limit = null, $offset = null) { |
|
| 57 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ? ORDER BY Dt DESC'; |
|
| 58 | - return $this->findEntities($sql, [$pollId], $limit, $offset); |
|
| 59 | - } |
|
| 50 | + /** |
|
| 51 | + * @param int $pollId |
|
| 52 | + * @param int $limit |
|
| 53 | + * @param int $offset |
|
| 54 | + * @return Comment[] |
|
| 55 | + */ |
|
| 56 | + public function findByPoll($pollId, $limit = null, $offset = null) { |
|
| 57 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ? ORDER BY Dt DESC'; |
|
| 58 | + return $this->findEntities($sql, [$pollId], $limit, $offset); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @param int $pollId |
|
| 63 | - */ |
|
| 64 | - public function deleteByPoll($pollId) { |
|
| 65 | - $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
| 66 | - $this->execute($sql, [$pollId]); |
|
| 67 | - } |
|
| 61 | + /** |
|
| 62 | + * @param int $pollId |
|
| 63 | + */ |
|
| 64 | + public function deleteByPoll($pollId) { |
|
| 65 | + $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
| 66 | + $this->execute($sql, [$pollId]); |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -35,16 +35,16 @@ |
||
| 35 | 35 | * @method void setType(integer $value) |
| 36 | 36 | */ |
| 37 | 37 | class Participation extends Model { |
| 38 | - protected $dt; |
|
| 39 | - protected $userId; |
|
| 40 | - protected $pollId; |
|
| 41 | - protected $type; |
|
| 38 | + protected $dt; |
|
| 39 | + protected $userId; |
|
| 40 | + protected $pollId; |
|
| 41 | + protected $type; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Participation constructor. |
|
| 45 | - */ |
|
| 46 | - public function __construct() { |
|
| 47 | - $this->addType('pollId', 'integer'); |
|
| 48 | - $this->addType('type', 'integer'); |
|
| 49 | - } |
|
| 43 | + /** |
|
| 44 | + * Participation constructor. |
|
| 45 | + */ |
|
| 46 | + public function __construct() { |
|
| 47 | + $this->addType('pollId', 'integer'); |
|
| 48 | + $this->addType('type', 'integer'); |
|
| 49 | + } |
|
| 50 | 50 | } |
@@ -28,64 +28,64 @@ |
||
| 28 | 28 | |
| 29 | 29 | class NotificationMapper extends Mapper { |
| 30 | 30 | |
| 31 | - public function __construct(IDBConnection $db) { |
|
| 32 | - parent::__construct($db, 'polls_notif', '\OCA\Polls\Db\Notification'); |
|
| 33 | - } |
|
| 31 | + public function __construct(IDBConnection $db) { |
|
| 32 | + parent::__construct($db, 'polls_notif', '\OCA\Polls\Db\Notification'); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @param int $id |
|
| 37 | - * @throws \OCP\AppFramework\Db\DoesNotExistException if not found |
|
| 38 | - * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result |
|
| 39 | - * @return Notification |
|
| 40 | - */ |
|
| 41 | - public function find($id) { |
|
| 42 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE id = ?'; |
|
| 43 | - return $this->findEntity($sql, [$id]); |
|
| 44 | - } |
|
| 35 | + /** |
|
| 36 | + * @param int $id |
|
| 37 | + * @throws \OCP\AppFramework\Db\DoesNotExistException if not found |
|
| 38 | + * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result |
|
| 39 | + * @return Notification |
|
| 40 | + */ |
|
| 41 | + public function find($id) { |
|
| 42 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE id = ?'; |
|
| 43 | + return $this->findEntity($sql, [$id]); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @param string $userId |
|
| 48 | - * @param string $from |
|
| 49 | - * @param string $until |
|
| 50 | - * @param int $limit |
|
| 51 | - * @param int $offset |
|
| 52 | - * @return Notification[] |
|
| 53 | - */ |
|
| 54 | - public function findBetween($userId, $from, $until, $limit = null, $offset = null) { |
|
| 55 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE userId = ? AND timestamp BETWEEN ? AND ?'; |
|
| 56 | - return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset); |
|
| 57 | - } |
|
| 46 | + /** |
|
| 47 | + * @param string $userId |
|
| 48 | + * @param string $from |
|
| 49 | + * @param string $until |
|
| 50 | + * @param int $limit |
|
| 51 | + * @param int $offset |
|
| 52 | + * @return Notification[] |
|
| 53 | + */ |
|
| 54 | + public function findBetween($userId, $from, $until, $limit = null, $offset = null) { |
|
| 55 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE userId = ? AND timestamp BETWEEN ? AND ?'; |
|
| 56 | + return $this->findEntities($sql, [$userId, $from, $until], $limit, $offset); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * @param int $limit |
|
| 61 | - * @param int $offset |
|
| 62 | - * @return Notification[] |
|
| 63 | - */ |
|
| 64 | - public function findAll($limit = null, $offset = null) { |
|
| 65 | - $sql = 'SELECT * FROM ' . $this->getTableName(); |
|
| 66 | - return $this->findEntities($sql, [], $limit, $offset); |
|
| 67 | - } |
|
| 59 | + /** |
|
| 60 | + * @param int $limit |
|
| 61 | + * @param int $offset |
|
| 62 | + * @return Notification[] |
|
| 63 | + */ |
|
| 64 | + public function findAll($limit = null, $offset = null) { |
|
| 65 | + $sql = 'SELECT * FROM ' . $this->getTableName(); |
|
| 66 | + return $this->findEntities($sql, [], $limit, $offset); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * @param int $pollId |
|
| 71 | - * @param int $limit |
|
| 72 | - * @param int $offset |
|
| 73 | - * @return Notification[] |
|
| 74 | - */ |
|
| 75 | - public function findAllByPoll($pollId, $limit = null, $offset = null) { |
|
| 76 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
| 77 | - return $this->findEntities($sql, [$pollId], $limit, $offset); |
|
| 78 | - } |
|
| 69 | + /** |
|
| 70 | + * @param int $pollId |
|
| 71 | + * @param int $limit |
|
| 72 | + * @param int $offset |
|
| 73 | + * @return Notification[] |
|
| 74 | + */ |
|
| 75 | + public function findAllByPoll($pollId, $limit = null, $offset = null) { |
|
| 76 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
| 77 | + return $this->findEntities($sql, [$pollId], $limit, $offset); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * @param int $pollId |
|
| 82 | - * @param string $userId |
|
| 83 | - * @throws \OCP\AppFramework\Db\DoesNotExistException if not found |
|
| 84 | - * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result |
|
| 85 | - * @return Notification |
|
| 86 | - */ |
|
| 87 | - public function findByUserAndPoll($pollId, $userId) { |
|
| 88 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ? AND user_id = ?'; |
|
| 89 | - return $this->findEntity($sql, [$pollId, $userId]); |
|
| 90 | - } |
|
| 80 | + /** |
|
| 81 | + * @param int $pollId |
|
| 82 | + * @param string $userId |
|
| 83 | + * @throws \OCP\AppFramework\Db\DoesNotExistException if not found |
|
| 84 | + * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result |
|
| 85 | + * @return Notification |
|
| 86 | + */ |
|
| 87 | + public function findByUserAndPoll($pollId, $userId) { |
|
| 88 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ? AND user_id = ?'; |
|
| 89 | + return $this->findEntity($sql, [$pollId, $userId]); |
|
| 90 | + } |
|
| 91 | 91 | } |
@@ -28,30 +28,30 @@ |
||
| 28 | 28 | |
| 29 | 29 | class TextMapper extends Mapper { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * TextMapper constructor. |
|
| 33 | - * @param IDBConnection $db |
|
| 34 | - */ |
|
| 35 | - public function __construct(IDBConnection $db) { |
|
| 36 | - parent::__construct($db, 'polls_txts', '\OCA\Polls\Db\Text'); |
|
| 37 | - } |
|
| 31 | + /** |
|
| 32 | + * TextMapper constructor. |
|
| 33 | + * @param IDBConnection $db |
|
| 34 | + */ |
|
| 35 | + public function __construct(IDBConnection $db) { |
|
| 36 | + parent::__construct($db, 'polls_txts', '\OCA\Polls\Db\Text'); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @param int $pollId |
|
| 41 | - * @param int $limit |
|
| 42 | - * @param int $offset |
|
| 43 | - * @return Text[] |
|
| 44 | - */ |
|
| 45 | - public function findByPoll($pollId, $limit = null, $offset = null) { |
|
| 46 | - $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
| 47 | - return $this->findEntities($sql, [$pollId], $limit, $offset); |
|
| 48 | - } |
|
| 39 | + /** |
|
| 40 | + * @param int $pollId |
|
| 41 | + * @param int $limit |
|
| 42 | + * @param int $offset |
|
| 43 | + * @return Text[] |
|
| 44 | + */ |
|
| 45 | + public function findByPoll($pollId, $limit = null, $offset = null) { |
|
| 46 | + $sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
| 47 | + return $this->findEntities($sql, [$pollId], $limit, $offset); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @param int $pollId |
|
| 52 | - */ |
|
| 53 | - public function deleteByPoll($pollId) { |
|
| 54 | - $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
| 55 | - $this->execute($sql, [$pollId]); |
|
| 56 | - } |
|
| 50 | + /** |
|
| 51 | + * @param int $pollId |
|
| 52 | + */ |
|
| 53 | + public function deleteByPoll($pollId) { |
|
| 54 | + $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE poll_id = ?'; |
|
| 55 | + $this->execute($sql, [$pollId]); |
|
| 56 | + } |
|
| 57 | 57 | } |
@@ -31,13 +31,13 @@ |
||
| 31 | 31 | * @method void setPollId(integer $value) |
| 32 | 32 | */ |
| 33 | 33 | class Text extends Model { |
| 34 | - protected $text; |
|
| 35 | - protected $pollId; |
|
| 34 | + protected $text; |
|
| 35 | + protected $pollId; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Text constructor. |
|
| 39 | - */ |
|
| 40 | - public function __construct() { |
|
| 41 | - $this->addType('pollId', 'integer'); |
|
| 42 | - } |
|
| 37 | + /** |
|
| 38 | + * Text constructor. |
|
| 39 | + */ |
|
| 40 | + public function __construct() { |
|
| 41 | + $this->addType('pollId', 'integer'); |
|
| 42 | + } |
|
| 43 | 43 | } |