我是laravel的新手,我一直在學習更多的東西。但是現在我得到了一個我在普通PHP中從未見過的錯誤。我在函數目錄中測試的某些運算符不起作用,而其他運算符則是這樣。只有=,!=和<>工作,而<,>,> =和< =沒有。運營商似乎沒有在Laravel工作
它給了我:「非法運營商和價值組合」;還有:->where('Price', '(operator)', **null**)
。我曾嘗試過「wherenull」但不起作用。任何人都可以幫我解決這個問題嗎?我正在使用laravel 5.4。
的代碼:
控制器(在這種情況下我已經把 「> =」 它不工作)
function catalog(Request $abc) {
$categoryesc = $abc->categoryesc;
$priceesc = $abc->priceesc;
$categories = DB::table('categories')->pluck('Category', 'id');
$robots = DB::table('robots')->where('Category_id', $categoryesc)->where('Price', '>=', $priceesc)->get();
return view('catalog', compact('robots', 'categories'));
}
視圖
@extends('layouts.layout')
@include('header')
<main>
<div>Choose the category</div>
{!! Form::open(array('method' => 'GET')) !!}
{!! Form::select('categoryesc', $categories) !!}
{{ Form::number('priceesc') }}
{!! Form::submit('Ok') !!}
{!! Form::close() !!}
<div>Choose the model</div>
<b>On this page ({{ $robots->count() }} robots)</b>
<div id="area1">
@foreach($robots as $robot)
{!! Form::open(array('action' => '[email protected]', 'method' => 'GET')) !!}
{!! Form::hidden('modelesc', $robot->Model) !!}
{!! Form::submit($robot->Model) !!}
{!! Form::close() !!}
@endforeach
</div>
</main>
完整的錯誤信息是:
Builder.php中的InvalidArgumentException l INE 609:非法運算符和值組合
表觀解
我認爲我已經解決了這個:我去到該文件在\vendor\laravel\framework\src\illuminate\database\query\builder.php
和線627增加了「< =」(下我想要使用的運算符)。現在它正在工作。否則我會在稍後回到這個。
可以提供錯誤的全文? – jackel414
請檢查您的數據類型?什麼類型是價格? – Boris
@ jacket414 - 完整的錯誤消息是:Builder.php中的InvalidArgumentException行609: 非法操作符和值組合。 – Adato