ile birden çok where yan tümcelerini kullanma Aşağıdaki SQL sorgusu laravels sorgu oluşturucu ile çalışmak için çok fazla sorun yaşıyorum.laravel sorgu oluşturucusu
SELECT * FROM gifts
JOIN giftcategory ON gifts.id = giftcategory.giftid
JOIN giftoccasions ON gifts.id = giftoccasions.giftid
JOIN giftrelationship ON gifts.id = giftrelationship.giftid
WHERE (gifts.gender = 'any' OR gifts.gender = 'male')
AND giftoccasions.occasionid = '2'
AND (giftcategory.categoryid = '0' OR giftcategory.categoryid = '1')
AND giftrelationship.relationshipid = '1'
Bu sorgu çalışıyor, ancak Laravels sorgu oluşturucu kullanırken i aynı sonuçları elde edemezsiniz. Şimdiye kadar aşağıdaki kod var. Hiç düzgün çalışmıyor. Sorunun, ya daWhere bölümü ile yatar olabileceğini düşünüyorum çünkü bu, diğer herhangi bir ifadeyle uyuşmayan sonuçları döndürüyor gibi görünüyor.
$giftQuery = DB::Table('gifts')
->Join('giftcategory', 'gifts.id', '=', 'giftcategory.giftid')
->Join('giftoccasions', 'gifts.id', '=', 'giftoccasions.giftid')
->where('gifts.gender', '=', "male")
->orwhere('gifts.gender', '=', "any")
->where('giftoccasions.occasionid', '=', "2")
->where('giftoccasions.relationshipid', '=', "1")
->Where('giftcategory.categoryid', '=', "0")
->orWhere('giftcategory.categoryid', '=', "1");
, bunu kabul edebilir :) –