mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 18:58:46 +02:00
Fixed order by FIELD emulation on sqlite via INSTR
We need to search for the comma token separators at both ends of the search term, otherwise the ordering will be wrong.
This commit is contained in:
parent
80ed064cd6
commit
11be65678e
1 changed files with 3 additions and 3 deletions
|
@ -66,9 +66,9 @@ final class FieldHelper
|
|||
private static function addSqliteOrderBy(QueryBuilder $qb, string $field_expr, string $key, array $values, ?string $order = null): void
|
||||
{
|
||||
//Otherwise we emulate it using
|
||||
$qb->orderBy("LOCATE(CONCAT($field_expr, ','), :$key)", $order);
|
||||
//The value have to end with a comma, otherwise the search using INSTR will fail
|
||||
$qb->setParameter($key, implode(',', $values) . ',');
|
||||
$qb->orderBy("LOCATE(CONCAT(',', $field_expr, ','), :$key)", $order);
|
||||
//The string must be padded with a comma on both sides, otherwise the search using INSTR will fail
|
||||
$qb->setParameter($key, ',' .implode(',', $values) . ',');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue