Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix filters #10

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/Db/PublicationMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use OCP\AppFramework\Db\Entity;
use OCP\AppFramework\Db\QBMapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\DB\Types;
use OCP\IDBConnection;

class PublicationMapper extends QBMapper
Expand All @@ -30,6 +31,9 @@ public function find(int $id): Publication

private function parseComplexFilter(IQueryBuilder $queryBuilder, array $filter, string $name): IQueryBuilder
{
var_dump($filter);
rjzondervan marked this conversation as resolved.
Show resolved Hide resolved


foreach($filter as $key => $value) {
switch($key) {
case '>=':
Expand All @@ -49,7 +53,7 @@ private function parseComplexFilter(IQueryBuilder $queryBuilder, array $filter,
$queryBuilder->andWhere($queryBuilder->expr()->lt($name, $queryBuilder->createNamedParameter($value)));
break;
default:
$queryBuilder->andWhere($queryBuilder->expr()->eq($name, $queryBuilder->createNamedParameter($filter)));
$queryBuilder->andWhere($queryBuilder->expr()->eq(x: $name, y: $queryBuilder->createNamedParameter($filter)));
}
}

Expand All @@ -60,7 +64,7 @@ private function addFilters(IQueryBuilder $queryBuilder, array $filters): IQuery
{
foreach($filters as $key => $filter) {
if(is_array($filter) === false) {
$queryBuilder->andWhere($queryBuilder->expr()->eq($key, $queryBuilder->createNamedParameter($key)));
$queryBuilder->andWhere($queryBuilder->expr()->eq($key, $queryBuilder->createNamedParameter($filter)));
$queryBuilder->setParameter($key, $filter);
continue;
}
Expand Down
Loading