I need magento sql collection.
Query need like that.
select * from custom_table where customer_id=xx or (customer_group=1 and custom_field=1)
I can add or operator like below
select * from custom_table where customer_id=xx or (customer_group=1)
But needs to and operator with second OR.
My Current collection:
$collection = $this->customTableFactory->create()->getCollection()->addFieldToFilter(
['customer_id','custom_field'],
[
['eq' =>$customerId],
['eq' =>1]
]);
Query From above collection:
SELECT main_table
.* FROM custom_table
AS main_table
WHERE ((customer_id
= 'xx') OR (custom_field
= 1))
But I want collection like as below: Need to add And condition in second OR
SELECT main_table
.* FROM custom_table
AS main_table
WHERE ((customer_id
= 'xx') OR (custom_field
= 1 and customer_group
=1))
Please help me if anyone get solution.
Thanks!