/** * @param array $data * @param integer $format * @return Subscription */ public function createEntity($data, $format = self::FORMAT_PARAM) { switch ($format) { case self::FORMAT_PARAM: return Subscription::fromParams($data); break; case self::FORMAT_ROW: return Subscription::fromRow($data); break; default: throw new \InvalidArgumentException('SubscriptionFactory::createEntity() - Unknown format given'); break; } }
/** * find subscription by id, type, userId * @param int $id * @param string $type * @param string $userId * @throws \OCP\AppFramework\Db\DoesNotExistException: if the item does not exist * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException: if more than one item found * @return Subscription object */ public function findByType($id, $type, $userId) { $sql = 'SELECT * FROM `' . $this->getTableName() . '` '; $sql .= 'WHERE `id` = ? AND `type` = ? AND `user_id`= ?'; $params = [$id, $type, $userId]; $row = $this->findOneQuery($sql, $params); return Subscription::fromRow($row); }