0

My query with whereIn only works with string array and integer array containing number < 10 ( example [1,2,3,4,5,6,7,8,9] will work ).

This will return an empty collection.

$sql = DB::table('simple_table');
$sql->whereIn('question_id', [10, 12);

And this will return the expected result.

// string array | work
$sql = DB::table('simple_table');
$sql->whereIn('question_id', ['10', '12']);

// integer array containing number < 10 | work
$sql = DB::table('simple_table');
$sql->whereIn('question_id', [1, 2]);

question_id field is string type.

With Laravel 5.2 and whereIn will work for both string and integer.

Any known issues or changes with whereIn in Laravel 5.8??

UPDATED

// work
DB::select('select * from outbound_questions where question_alias IN (10, 12)')
// not work
DB::select('select * from outbound_questions where question_alias IN (?)', [10])

I updated Laravel to 6.x and PHP 7.3, the issue still there...

HVD
  • 231
  • 1
  • 13
  • What's your question? – STA Jan 13 '21 at 09:22
  • @sta Sorry you, my english is bad. My question is "Any known issues or changes with whereIn in Laravel 5.8??" – HVD Jan 13 '21 at 09:25
  • I doubled check on my local, it work just fine. There are no chances on whereIn clause. – Ahmad Karimi Jan 13 '21 at 20:34
  • @AhmadKarimi Laravel 5.2 it's work fine. Still don't know why I have this issue. I'm trying to test another version. Thank you. – HVD Jan 14 '21 at 02:31
  • @AhmadKarimi I updated Laravel to 6.x and PHP 7.3 and the issue still there... – HVD Jan 14 '21 at 08:22
  • I have no idea about this mystical issue – Ahmad Karimi Jan 14 '21 at 08:58
  • @AhmadKarimi Seem like the issue comes from PHP version. Using Laravel 5.4, PHP 5.6.40 works fine. Maybe related to PDO issue on PHP 7. https://stackoverflow.com/questions/54413798/pdoparam-int-behaviour-in-php-7-1-php-7-2 – HVD Jan 14 '21 at 09:30

0 Answers0