Closed Krzysiu closed 7 years ago
In this special case, you can do this with commented key.
$database->select('foo', 'id', [
'OR' => [
'AND #Null' => [
'description' => null
],
'AND #Empty' => [
'description' => ''
]
]
]);
// Or simplified:
$database->select('foo', 'id', [
'OR' => [
'description' => null,
'AND #Empty' => [
'description' => ''
]
]
]);
Thanks, that does the trick!
// Or further simplified:
$database->select('foo', 'id', [
'OR' => [
'description' => null,
'description #empty' => ''
]
]);
How to select rows with WHERE with both NULL or empty string? I tried:
$db->select('foo', 'id', XXX);
whereXXX
was:['OR' => ['description' => null], ['description' => '']]
(Medoo changes it toWHERE description IS NULL
)['AND' => ['OR' => ['description' => null]], ['OR' => ['description' => '']]]
(I get warning:PDO::quote() expects parameter 1 to be string, array given
)['description' => [null, '']]
(Medoo changes it toWHERE description IN ('','')
)Of course I can make raw query, but I'd love to use native way to get something, that would result
WHERE value = '' OR value IS null
. When I do ['value' => null] it works well. It just fails when there's NULL or something other.