Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Larvel,其中“小于”查询未显示预期结果_Php_Mysql_Laravel_Eloquent - Fatal编程技术网

Php Larvel,其中“小于”查询未显示预期结果

Php Larvel,其中“小于”查询未显示预期结果,php,mysql,laravel,eloquent,Php,Mysql,Laravel,Eloquent,我试图进行一个数据库查询,搜索当前级别低于低库存级别的所有项目。当运行查询时,我没有得到任何结果,我不知道为什么 这是我的问题 public static function getLowStockItemsCache() { dd(\DB::table('items')->where('current_level', '<', 'low_stock_level')->get()); } 当我死后把它扔掉,我得到一个空的收藏 在我的数据库中,我有以下记

我试图进行一个数据库查询,搜索当前级别低于低库存级别的所有项目。当运行查询时,我没有得到任何结果,我不知道为什么

这是我的问题

public static function getLowStockItemsCache()
{
         dd(\DB::table('items')->where('current_level', '<', 'low_stock_level')->get());
    }
当我死后把它扔掉,我得到一个空的收藏

在我的数据库中,我有以下记录

这两个字段都设置为int11

如果我撤销查询,我会得到所有13条记录


我是否遗漏了一些小的东西,因为这让我非常困惑,而且应该很简单。

第三个参数是value参数,这意味着在构建查询时将对其进行转义,以避免SQL注入。如果要比较两列,必须明确告诉查询生成器不应处理查询的该部分,方法是使用whereRaw传递原始SQL条件:

\DB::表'items'->其中原始'current_level获取; 或者只对值使用DB::raw,因此不会转义:


\DB::table'items'->where'current_level',“Laravel在where子句上使用三步参数

Pair::where('1st','2nd','3rd')
默认情况下,第二个arg通常是默认等号,表示第一个arg等于第三个arg

Pair::where('name', 'john')->get();

Pair::where('stock', '<', '100')->get();

当你找到这个逻辑,你就会明白where技巧

试试whereRaw'current_level