yii2-redis icon indicating copy to clipboard operation
yii2-redis copied to clipboard

Yii2-redis when we do not need select database, will be wrong

Open emmayliu01 opened this issue 7 years ago • 3 comments

What steps will reproduce the problem?

当使用某些公司内部redis服务时,是通过bns来获取连接的ip,并不需要select database,这样会报错

What's expected?

所以希望当没有配置database时,默认为null want in Connection.php line70 public $database = null; line290 if ($this->database !== null){ $this->executeCommand('SELECT', [$this->database]);
} but now in Connection.php line70 public $database = 0; line290 $this->executeCommand('SELECT', [$this->database]);

Additional info

Q A
Yii 2
PHP version 7.1.11
Operating system centos 6.3

emmayliu01 avatar May 07 '18 08:05 emmayliu01

default redis setup does not require SELECT, so the default of null is fine. if your environment requires SELECT, just configure the DB to be different from null.

cebe avatar May 07 '18 08:05 cebe

but now in Connection.php, the program must run the line 290 $this->executeCommand('SELECT', [$this->database]); when we do not require SELECT database, it will throw Database Exception. The current code is not supported if we do not require SELECT database. Will the code support the database default is null in the future?

emmayliu01 avatar May 07 '18 08:05 emmayliu01

if you don't want to select a database, just configure database property to be null.

cebe avatar May 08 '18 09:05 cebe