Laravel DB :: RAW()不在工作

时间:2015-12-15 16:47:15

标签: php mysql laravel-4

你好cards表上有5条记录, 当我不在phpmyadmin工作时使用

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

enter image description here

但是当我在Laravel上没有使用它时它没有工作,它只能在第一次绑定

$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

我使用本指南来避免SQL注入: http://fideloper.com/laravel-raw-queries

1 个答案:

答案 0 :(得分:1)

DB :: table(&#39; cards&#39;) - &gt; whereRaw(&#39; id not IN(&#34;。$ test。&#34;)&#39;) - &gt ;得到();

请尝试使用此代码。

相关问题