Use $query->whereIn() in a frontend model, with an array with more than 1 item.
Sometimes only 1 row is returned.
all rows for the array in the where in returned
only some rows are returned
Database Type mysql
Database Version 5.6.49
Database Collation utf8_general_mysql500_ci
Database Connection Collation utf8mb4_general_ci
Database Connection Encryption None
Database Server Supports Connection Encryption No
PHP Version 7.4.11
Web Server Apache
WebServer to PHP Interface litespeed
Joomla! Version Joomla! 4.0.0-beta5-dev Development [ Mañana ] 15-September-2020 19:15 GMT
User Agent Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36
$query->whereIn('u.
id', $users);
- returns only 1 of 4 $users from the array
$query->where('u.
id IN(' . implode(',', $db->quote($users)) . ')');
- works as expected and returns all 4 $users in the array
Labels |
Added:
Information Required
|
Check if your $users
array uses numerical indexes which are also linearly incremented by 1.
You can call
$users = array_values($users);
before the whereIn
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-10-31 15:24:28 |
Closed_By | ⇒ | Quy |
This and related database query methods expect an indexed array?♂️ .