diff --git a/Classes/Domain/Repository/LogRepository.php b/Classes/Domain/Repository/LogRepository.php index 0995744..7911712 100644 --- a/Classes/Domain/Repository/LogRepository.php +++ b/Classes/Domain/Repository/LogRepository.php @@ -30,7 +30,7 @@ public function getNumberOfReceivers(Filter $filter): int . ' left join ' . Newsletter::TABLE_NAME . ' nl on nl.uid=l.newsletter' . ' left join ' . Configuration::TABLE_NAME . ' c on nl.configuration=c.uid' . ' where l.deleted=0 and l.status=' . Log::STATUS_DISPATCH - . ' and c.site in ("' . implode('","', $filter->getSitesForFilter()) . '")' + . ' and c.site in (\'' . implode('\',\'', $filter->getSitesForFilter()) . '\')' . ' and nl.crdate>' . $filter->getTimeDateStart()->getTimestamp() . ' limit 1'; return (int)$connection->executeQuery($sql)->fetchOne(); @@ -57,7 +57,7 @@ public function getGroupedLinksByHref(Filter $filter): array . ' left join ' . Newsletter::TABLE_NAME . ' nl on nl.uid=l.newsletter' . ' left join ' . Configuration::TABLE_NAME . ' c on nl.configuration=c.uid' . ' where l.deleted=0 and l.status=' . Log::STATUS_LINKOPENING - . ' and c.site in ("' . implode('","', $filter->getSitesForFilter()) . '")' + . ' and c.site in (\'' . implode('\',\'', $filter->getSitesForFilter()) . '\')' . ' and nl.crdate>' . $filter->getTimeDateStart()->getTimestamp() . ' group by l.properties, l.newsletter' . ' order by count desc' @@ -79,13 +79,13 @@ public function getGroupedLinksByHref(Filter $filter): array public function getOverallOpenings(Filter $filter): int { $connection = DatabaseUtility::getConnectionForTable(Log::TABLE_NAME); - $sql = 'select count(distinct newsletter, user)' + $sql = 'select count(distinct (newsletter, user))' . ' from ' . Log::TABLE_NAME . ' l' . ' left join ' . Newsletter::TABLE_NAME . ' nl on nl.uid=l.newsletter' . ' left join ' . Configuration::TABLE_NAME . ' c on nl.configuration=c.uid' . ' where l.deleted = 0' . ' and l.status IN (' . Log::STATUS_NEWSLETTEROPENING . ',' . Log::STATUS_LINKOPENING . ')' - . ' and c.site in ("' . implode('","', $filter->getSitesForFilter()) . '")' + . ' and c.site in (\'' . implode('\',\'', $filter->getSitesForFilter()) . '\')' . ' and nl.crdate>' . $filter->getTimeDateStart()->getTimestamp(); return (int)$connection->executeQuery($sql)->fetchOne(); } @@ -98,12 +98,12 @@ public function getOverallOpenings(Filter $filter): int public function getOpeningsByClickers(Filter $filter): int { $connection = DatabaseUtility::getConnectionForTable(Log::TABLE_NAME); - $sql = 'select count(distinct newsletter, user)' + $sql = 'select count(distinct (newsletter, user))' . ' from ' . Log::TABLE_NAME . ' l' . ' left join ' . Newsletter::TABLE_NAME . ' nl on nl.uid=l.newsletter' . ' left join ' . Configuration::TABLE_NAME . ' c on nl.configuration=c.uid' . ' where l.deleted = 0 and l.status=' . Log::STATUS_LINKOPENING - . ' and c.site in ("' . implode('","', $filter->getSitesForFilter()) . '")' + . ' and c.site in (\'' . implode('\',\'', $filter->getSitesForFilter()) . '\')' . ' and nl.crdate>' . $filter->getTimeDateStart()->getTimestamp(); return (int)$connection->executeQuery($sql)->fetchOne(); } @@ -152,7 +152,7 @@ protected function getOverallAmountByLogStatus(array $status, Filter $filter): i . ' left join ' . Newsletter::TABLE_NAME . ' nl on nl.uid=l.newsletter' . ' left join ' . Configuration::TABLE_NAME . ' c on nl.configuration=c.uid' . ' where l.deleted = 0 and l.status in (' . ArrayUtility::convertArrayToIntegerList($status) . ')' - . ' and c.site in ("' . implode('","', $filter->getSitesForFilter()) . '")' + . ' and c.site in (\'' . implode('\',\'', $filter->getSitesForFilter()) . '\')' . ' and nl.crdate>' . $filter->getTimeDateStart()->getTimestamp(); return (int)$connection->executeQuery($sql)->fetchOne(); } @@ -275,7 +275,7 @@ public function isLogRecordExisting(int $newsletterIdentifier, int $userIdentifi $uid = (int)$queryBuilder ->select('uid') ->from(Log::TABLE_NAME) - ->where('newsletter=' . $newsletterIdentifier . ' and user=' . $userIdentifier . ' and status=' . $status) + ->where('newsletter=' . $newsletterIdentifier . ' and user=\'' . $userIdentifier . '\' and status=\'' . $status . '\'') ->setMaxResults(1) ->executeQuery() ->fetchOne(); @@ -312,7 +312,7 @@ public function findByNewsletterAndStatus(Newsletter $newsletter, array $status, public function findRawByUser(User $user, array $statusWhitelist = [], array $statusBlacklist = []): array { $connection = DatabaseUtility::getConnectionForTable(Log::TABLE_NAME); - $sql = 'select * from ' . Log::TABLE_NAME . ' where deleted=0 and user=' . $user->getUid(); + $sql = 'select * from ' . Log::TABLE_NAME . ' where deleted=0 and user=\'' . $user->getUid() . '\''; if ($statusWhitelist !== []) { $sql .= ' and status in (' . implode(',', $statusWhitelist) . ')'; } elseif ($statusBlacklist !== []) { diff --git a/Classes/Domain/Repository/QueueRepository.php b/Classes/Domain/Repository/QueueRepository.php index 2d4e2db..30c51b2 100644 --- a/Classes/Domain/Repository/QueueRepository.php +++ b/Classes/Domain/Repository/QueueRepository.php @@ -94,7 +94,7 @@ public function isUserAndNewsletterAlreadyAddedToQueue(User $user, Newsletter $n return (int)$queryBuilder ->select('uid') ->from(Queue::TABLE_NAME) - ->where('newsletter=' . $newsletter->getUid() . ' and user=' . $user->getUid()) + ->where('newsletter=' . $newsletter->getUid() . ' and user=\'' . $user->getUid() . '\'') ->setMaxResults(1) ->executeQuery() ->fetchOne() > 0; diff --git a/Classes/Domain/Repository/UserRepository.php b/Classes/Domain/Repository/UserRepository.php index 176ecdf..160e867 100644 --- a/Classes/Domain/Repository/UserRepository.php +++ b/Classes/Domain/Repository/UserRepository.php @@ -96,7 +96,7 @@ public function getUserAmountFromGroups(array $groupIdentifiers): int } $sub .= 'find_in_set(' . (int)$identifier . ',usergroup)'; } - $sql .= ' where deleted=0 and disable=0 and email like "%@%" and (' . $sub . ')'; + $sql .= ' where deleted=0 and disable=0 and email like \'%@%\' and (' . $sub . ')'; return (int)$connection->executeQuery($sql)->fetchOne(); } return 0;