Yii2: FIND_IN_SET with WHERE in Active Record?

Created on 4 Dec 2015  路  2Comments  路  Source: yiisoft/yii2

Is there a way to use FIND_IN_SET with WHERE without using findBySql in Active Record?

If not, could this be implemented? tnx.

PS: i don't get any answers about that on: http://www.yiiframework.com/forum/index.php/topic/68741-yii2-active-record-where-find-in-set/

Most helpful comment

Your should use yii\db\Expression:

User::find()->where(new Expression('FIND_IN_SET(:status, status)'))->addParams([':status' => 1])->all();

All 2 comments

Your should use yii\db\Expression:

User::find()->where(new Expression('FIND_IN_SET(:status, status)'))->addParams([':status' => 1])->all();
Was this page helpful?
0 / 5 - 0 ratings