1

Hello I have 5 records on cards table, and when I use not in on phpmyadmin it's working

SELECT id FROM cards WHERE id NOT IN (1,2)

enter image description here

but when I used not in on Laravel it's not working, and it only bind on 1st

$test = "1,2";

$cards = DB::SELECT(DB::RAW("SELECT id FROM cards WHERE id NOT IN (:exception)"), ['exception'=>$test]);

echo "<pre>";
var_dump($cards);
echo "</pre>";

enter image description here

I'm using this guide to avoid SQL Injection: http://fideloper.com/laravel-raw-queries

Storm Spirit
  • 1,440
  • 4
  • 19
  • 42

1 Answers1

3
DB::table('cards')->whereRaw('id NOT IN(".$test.")')->get();

Please try this code instead.

Regolith
  • 2,944
  • 9
  • 33
  • 50