$price = DB::table('price')
->where([
['days_id', $days AND 'deals_id', $selected_deal] ])
->pluck('price');
我使用此代碼來獲得單一價格,但它給我所有的價格,這些條件來了。如何從laravel中的表中檢索單個字段5.2
$price = DB::table('price')
->where([
['days_id', $days AND 'deals_id', $selected_deal] ])
->pluck('price');
我使用此代碼來獲得單一價格,但它給我所有的價格,這些條件來了。如何從laravel中的表中檢索單個字段5.2
這兩個過濾器都很重要。我想只有一個領域這些都mathes –
$價格= DB ::表('價格') - >其中(['days_id','2'和'deals_id','4']]) - >拔毛( '價格'); Illuminate \ Support \ Collection對象([items:protected] => Array([0] => 40 [1] => 60 [2] => 80 [3] => 100) 這是給我的這些結果 [4] => 120 [5] => 140)) –
使用value()方法,你可以得到一個價值/場從表中你想
$price = DB::table('price')
->where([
['days_id', $days AND 'deals_id', $selected_deal] ])
->value('price');
當我從你的問題,你應該只是總結了那些懂了吧? –
沒有先生,我只想要一個價格不多 –
解析代碼後,您的代碼將返回'price'表中找到的每個實例的'price'。 –