X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FDatabase%2FDBA.php;h=f3edf52be5f1e973f940402db42ff6cc90b5d16b;hb=f4e1acedfcd86c81403c14747ecfd3b11583506e;hp=9825d06c683a7791fee2a9ff95e9d7ff43f0b3e2;hpb=24713e289eb2eb2ba0e21a0c603db324b5d79b05;p=friendica.git diff --git a/src/Database/DBA.php b/src/Database/DBA.php index 9825d06c68..f3edf52be5 100644 --- a/src/Database/DBA.php +++ b/src/Database/DBA.php @@ -648,6 +648,20 @@ class DBA /** * Returns the SQL parameter string built from the provided parameter array * + * Expected format for each key: + * + * group_by: + * - list of column names + * + * order: + * - numeric keyed column name => ASC + * - associative element with boolean value => DESC (true), ASC (false) + * - associative element with string value => 'ASC' or 'DESC' literally + * + * limit: + * - single numeric value => count + * - list with two numeric values => offset, count + * * @param array $params * @return string */ @@ -665,7 +679,11 @@ class DBA if ($order === 'RAND()') { $order_string .= "RAND(), "; } elseif (!is_int($fields)) { - $order_string .= self::quoteIdentifier($fields) . " " . ($order ? "DESC" : "ASC") . ", "; + if ($order !== 'DESC' && $order !== 'ASC') { + $order = $order ? 'DESC' : 'ASC'; + } + + $order_string .= self::quoteIdentifier($fields) . " " . $order . ", "; } else { $order_string .= self::quoteIdentifier($order) . ", "; }