S
S
Sergey Beloventsev2019-05-09 16:30:22
Yii
Sergey Beloventsev, 2019-05-09 16:30:22

How to get all the data from a request?

I make a request

Goods::find()
      ->joinWith('addfeilds')
      ->where(['have'=>self::HAVE])
      ->andWhere(['or',['key_feild'=>'color'],['key_feild'=>'size1']])
      ->orderBy(['id'=>SORT_ASC])
      ->limit(10);

then I process it like this
$count=1;
   foreach ($query->each(100) as $model) {
       echo $count;
       $count++;
   }

I get 1,2,3,4,5 however if I then make a request in the console
SELECT `abh_gods`.* FROM `abh_gods` LEFT JOIN `abh_addlfeild` ON `abh_gods`.`id` = `abh_addlfeild`.`id_gods` WHERE (`have`=0) AND ((`key_feild`='color') OR (`key_feild`='size1')) ORDER BY `id` LIMIT 10

In request I receive ten results.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question