QueryBuilder andWhere simplify brackets

Hello to all!

Have anyone meet such thing?

I have a code - search for analogs for the product based on params

php code

But this just for illustration of a problem with QueryBuilder.

A chain of andWhere calls makes a query like this:

generated sql

While I want it to look like this:

wanted sql

Less brackets, simplier, and generated sql hangs on my server(but stil works on dev machines), while wanted is OK.

So, how can I make WHERE part much easier. I know I can make a WHERE string which should solve my issue, but this is not the best way, I hope.

maybe instead


->andWhere()

better will be


->where(['and',[],[],...])