ineersa
ineersa

Reputation: 3435

CDbCriteria and mysql USE INDEX()

I got problem with active record in yii. So the basic problem is how to define USE INDEX() mySQL criteria as CDbCriteria to pass it to CActivedataprovider. I didn't find it in api or in code. Maybe someone already had this problem before and can share his solution.

Thank you.

Upvotes: 3

Views: 1092

Answers (3)

mathematicalman
mathematicalman

Reputation: 306

If you use yii2 you can do it like this:

$yourQuery = YourModel::find()
        ->select(['*'])
        ->from(['yourTable USE INDEX(index1, index2, index3)']);

Upvotes: 1

ineersa
ineersa

Reputation: 3435

I found the solution. https://github.com/yiisoft/yii/issues/1385 this hack helps with simple selects and indexes.

Upvotes: 2

Valery Viktorovsky
Valery Viktorovsky

Reputation: 6726

It's impossible to do for AR. You should rewrite your code to DAO.

Upvotes: 0

Related Questions