mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-12 01:54:26 +02:00
Add expected support for sort strings in select() parameters
- Fix unexpected behaviors with calls already using the sort strings
This commit is contained in:
parent
a9af0ca26e
commit
d5acd5f96a
2 changed files with 38 additions and 14 deletions
|
@ -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) . ", ";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue