toArray(); $providerData = $provider->toArray(); $params = [ ':userId' => $providerData['id'], ':eventId' => $eventData['id'], ]; try { $statement = $this->connection->prepare( "INSERT INTO {$this->table} ( `userId`, `eventId` ) VALUES ( :userId, :eventId )" ); $res = $statement->execute($params); if (!$res) { throw new QueryExecutionException('Unable to add data in ' . __CLASS__); } return $this->connection->lastInsertId(); } catch (\Exception $e) { throw new QueryExecutionException('Unable to add data in ' . __CLASS__); } } /** * @param int eventId * * @return bool * @throws QueryExecutionException */ public function deleteByEventId($eventId) { try { $statement = $this->connection->prepare("DELETE FROM {$this->table} WHERE eventId = :eventId"); $statement->bindParam(':eventId', $eventId); return $statement->execute(); } catch (\Exception $e) { throw new QueryExecutionException('Unable to delete data from ' . __CLASS__, $e->getCode(), $e); } } }