O
O
oleg2016-10-31 13:40:14
MySQL
oleg, 2016-10-31 13:40:14

Why doesn't limit() work in yii2?

Good afternoon! Here's a simple query:
$query->andWhere(['online' => 1, 'rooms' => 1])->limit(2);
I receive sampling - the limit does not work. offset - similar.
What am I doing wrong?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Timofeev, 2016-10-31
@webinar

Your code is correct. The problem is elsewhere. Show all code.

M
Maxim Fedorov, 2016-10-31
@qonand

Most likely you change this limit somewhere. For example, in the DataProvider - it automatically sets its values ​​to limit and offset depending on the pagination settings

V
Vitaliy Orlov, 2016-10-31
@orlov0562

Try to see the resulting sql

var_dump($query->prepare(Yii::$app->db->queryBuilder)->createCommand()->rawSql);
exit();

before return $query;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question