I have a query Product::find()->joinWith('sizes')->all(); - 9 lines

request Product::find()->joinWith('sizes')->limit(6)->all(); - 3 lines

I can not understand why in the second case the limit is not correct

  • if Product::find()->joinWith('sizes')->distinct('id')->limit(6)->all(); - 6 lines as needed, but for some strange reason - Vladimir Vasilev
  • check the sql query itself, which is executed, it's not about the limit, but about joinWith - which is probably an INNER JOIN - which can reduce the number of rows in the response. - Goncharov Alexander
  • LEFT JOIN is used. All figured out how the limit of rows is considered. there is one product in the row but different sizes (in my case, it turned out 4 rows with one product, but different sizes), therefore it saves the distinct product id, and connects the size table so that you can filter the sample by them and other product columns. - Vladimir Vasilev

0