yiisoft / yii2-redis

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

how to use transaction by yii2-redis? #153

Closed twolier closed 6 years ago

twolier commented 6 years ago

What steps will reproduce the problem?

1. Yii::$app->redis ->multi() ->set('name','hello') ->get('name') ->set('nick','world') ->get('nick') ->exec(); PHP Fatal Error – yii\base\ErrorException Call to a member function set() on boolean

2. Yii::$app->redis->multi(); Yii::$app->redis->set('name','hello'); Yii::$app->redis->get('name'); Yii::$app->redis->set('nick','world'); Yii::$app->redis->get('nick'); Yii::$app->redis->exec();

Unknown Property – yii\base\UnknownPropertyException Getting unknown property: yii\web\Application::redis

What's expected?

Are there any examples ?

rob006 commented 6 years ago

Yii::$app->redis->exec();

Unknown Property – yii\base\UnknownPropertyException Getting unknown property: yii\web\Application::redis

It looks like you don't have configured redis component in your app.

yii-bot commented 6 years ago

Thank you for your question. In order for this issue tracker to be effective, it should only contain bug reports and feature requests.

We advise you to use our community driven resources:

If you are confident that there is a bug in the framework, feel free to provide information on how to reproduce it. This issue will be closed for now.

This is an automated comment, triggered by adding the label question.

twolier commented 6 years ago

@rob006 it's my fault I'm doing a return here Yii::$app->redis->exec(); So, throw an error Invalid Parameter – yii\base\InvalidParamException Response content must not be an array.

It should look something like this Yii::$app->redis->multi(); ...... Yii::$app->redis->exec(); return true;

Not like that return Yii::$app->redis->exec();