Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
emmayliu01 opened this issue May 7, 2018 · 3 comments
Open

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

emmayliu01 opened this issue May 7, 2018 · 3 comments

Comments

@emmayliu01
Copy link

emmayliu01 commented May 7, 2018

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 emmayliu01 changed the title Yii2-redis when we do not need select database, will bu wrong Yii2-redis when we do not need select database, will be wrong May 7, 2018
@cebe
Copy link
Member

cebe commented May 7, 2018

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.

@emmayliu01
Copy link
Author

emmayliu01 commented May 7, 2018

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?

@cebe
Copy link
Member

cebe commented May 8, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants