mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +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);
|
||||
|
||||
//If we are on MySQL, we can just use the FIELD function
|
||||
if ($db_platform instanceof AbstractMySQLPlatform) {
|
||||
//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 || $db_platform instanceof PostgreSQLPlatform) {
|
||||
$qb->orderBy("FIELD($field_expr, :field_arr)", $order);
|
||||
} else {
|
||||
//Generate a unique key from the field_expr
|
||||
|
||||
//Otherwise we have to it using the FIELD2 function
|
||||
//Otherwise use the portable version using string concatenation
|
||||
self::addSqliteOrderBy($qb, $field_expr, $key, $values, $order);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue