mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Use the FIELD function on postgres for order by field value
This commit is contained in:
parent
d7a7e22e5a
commit
8a42dfa154
1 changed files with 3 additions and 5 deletions
|
@ -87,13 +87,11 @@ final class FieldHelper
|
||||||
|
|
||||||
$key = 'field2_' . md5($field_expr);
|
$key = 'field2_' . md5($field_expr);
|
||||||
|
|
||||||
//If we are on MySQL, we can just use the FIELD function
|
//If we are on MySQL, we can just use the FIELD function, for postgres we can use our custom defined one
|
||||||
if ($db_platform instanceof AbstractMySQLPlatform) {
|
if ($db_platform instanceof AbstractMySQLPlatform || $db_platform instanceof PostgreSQLPlatform) {
|
||||||
$qb->orderBy("FIELD($field_expr, :field_arr)", $order);
|
$qb->orderBy("FIELD($field_expr, :field_arr)", $order);
|
||||||
} else {
|
} else {
|
||||||
//Generate a unique key from the field_expr
|
//Otherwise use the portable version using string concatenation
|
||||||
|
|
||||||
//Otherwise we have to it using the FIELD2 function
|
|
||||||
self::addSqliteOrderBy($qb, $field_expr, $key, $values, $order);
|
self::addSqliteOrderBy($qb, $field_expr, $key, $values, $order);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue