Pergunta

I wish to know how to write the following in laravel:

SELECT * FROM items WHERE item_id = $id AND item_category = $cat AND item_price = $price;

$id, $cat and $price are dynamically passed unto the query. Thanks.

Foi útil?

Solução

Eloquent

Item::where('item_id', $id)
->where('item_category', $cat)
->where('item_price', $price)
->get();

Fluent

DB::table('items')
->where('item_id', $id)
->where('item_category', $cat)
->where('item_price', $price)
->get();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top