A
A
andr20172016-08-16 12:20:45
Yii
andr2017, 2016-08-16 12:20:45

Which pagination widget to choose in Yii 1?

I do a search, the categories are more authoritative in this search, respectively, from the beginning there is a search by category, then by the rest of the conditions, and 2 queries are combined and they need to be paginated, as I understand it CDbCriteria is not suitable for these purposes.
How is it generally better to implement this in yii, and how to break it line by line.
(SELECT a.id, a.name, a.category_id, c.name
FROM articles a
LEFT JOIN categories c ON c.id = a.category_id
WHERE c.name LIKE '%December%')
UNION
(SELECT a.id, a.name, a.category_id, c.name
FROM `articles` a
LEFT JOIN categories c ON c.id = a.category_id
WHERE a.name LIKE '%brand%' OR
a.content LIKE '%brand%')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2016-08-16
@andr2017

1. CDbCriteria - doesn't do pagination, it's a query builder. And even more so, it is not a widget.
2. I highly recommend switching to yii2
3. Use CActiveDataProvider - www.yiiframework.com/doc/api/1.1/CActiveDataProvider pass it to a widget (CGridView or CListView) that has pagination. You can prepare data for this without activeRecords
4. See also this option: www.yiiframework.com/wiki/517/multiple-cactivedata...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question