【发布时间】:2013-08-08 08:54:55
【问题描述】:
我正在使用codigniter-redis 库在codeigniter 框架中使用redis。我已将Redis.php( 库文件) 放在应用程序/库中,将redis.php( 配置文件) 放在应用程序/配置中
这是我的代码
class Test extends Controller {
function __construct()
{
log_msg('info', "loading redis");
$this->load->library('redis', array('connection_group' => 'default'), 'redis_default');
}
function index()
{
$this->redis->command('PING');
}
当我从浏览器调用测试控制器时,它给了我错误
Message: Undefined property: Test::$redis
Filename: controllers/test.php
但它在日志文件中显示了适当的日志,一个如上所示,一个我放入 Redis.php 函数 _construct 告诉我连接成功
if ( ! $this->_connection)
{
show_error('Could not connect to Redis at ' . $config['host'] . ':' . $config['port']);
}
else
{
log_msg('info', "connection successful");
}
【问题讨论】:
标签: php codeigniter redis codeigniter-2