yiisoft / yii2-redis

Yii 2 Redis extension.
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
451 stars 184 forks source link

LIKE conditions are not suppoerted by redis ActiveRecord #244

Closed Geowan closed 2 years ago

Geowan commented 2 years ago

What steps will reproduce the problem?

  class UserRedisModel extends \yii\redis\ActiveRecord
      public static function keyPrefix()
      {
          return 'users'; // TODO: Change the autogenerated stub
      }

     public function attributes()
      {
       return [ 'id',  'first_name', 'last_name','status'  ];
       }

   }

Now am using the above redisActive record model like

 UserRedisModel::find()->where(['status' => [1, 5]])
        ->andFilterWhere([
            'or',
            ['like', 'first_name', 'a'],
        ])->all();

What's expected?

I expected to get all users with first name that has a. In the yii\db\ActiveRecord the above works but not on redis Active record

What do you get instead?

Am getting an error LIKE conditions are not suppoerted by redis ActiveRecord.

Additional info

Q A
Yii vesion 2.0.0
PHP version 7.4.3
Operating system Linux
bizley commented 2 years ago

Yes, because it's Redis, and not SQL. Try using directly commands like SCAN and similar.