Thanks to visit codestin.com
Credit goes to github.com

Skip to content

getLastError can't get some error #540

@tjuqxy

Description

@tjuqxy

Hi, I met an question about getLastError, following is code and result, who can tell me why

Code:
$redis = new Redis();
$redis->connect('127.0.0.1', 7100);
$redis->set('mykey', 'value');
$ret = $redis->get('mykey');
var_dump($ret);
$ret = $redis->lrange('mykey', 0, -1);
var_dump($ret);
$ret = $redis->getLastError();
var_dump($ret);

Result:
string(5) "value"
bool(false)
NULL

Execute in redis-cli:
redis 127.0.0.1:7100> get mykey
(nil)
redis 127.0.0.1:7100> set mykey value
OK
redis 127.0.0.1:7100> get mykey
"value"
redis 127.0.0.1:7100> lrange mykey 0 -1
(error) WRONGTYPE Operation against a key holding the wrong kind of value
redis 127.0.0.1:7100>

Redis version: 2.8.9
phpredis version: 2.2.6
PHP version: 5.2.17

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions