mirror of
https://github.com/friendica/friendica
synced 2024-11-19 02:23:41 +00:00
Merge pull request #8005 from MrPetovan/bug/7992-empty-in-clause
Add support for empty values array in Database\DBA
This commit is contained in:
commit
221746bff3
1 changed files with 29 additions and 24 deletions
|
@ -543,6 +543,7 @@ class DBA extends BaseObject
|
|||
$condition_string .= " AND ";
|
||||
}
|
||||
if (is_array($value)) {
|
||||
if (count($value)) {
|
||||
/* Workaround for MySQL Bug #64791.
|
||||
* Never mix data types inside any IN() condition.
|
||||
* In case of mixed types, cast all as string.
|
||||
|
@ -570,6 +571,10 @@ class DBA extends BaseObject
|
|||
$new_values = array_merge($new_values, array_values($value));
|
||||
$placeholders = substr(str_repeat("?, ", count($value)), 0, -2);
|
||||
$condition_string .= self::quoteIdentifier($field) . " IN (" . $placeholders . ")";
|
||||
} else {
|
||||
// Empty value array isn't supported by IN and is logically equivalent to no match
|
||||
$condition_string .= "FALSE";
|
||||
}
|
||||
} elseif (is_null($value)) {
|
||||
$condition_string .= self::quoteIdentifier($field) . " IS NULL";
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue