具有参数的Codeigniter自动加载库

时间:2013-01-07 10:15:08

标签: php codeigniter autoload filemaker

我正在使用FX.php和Codeigniter来访问Filemaker数据库。库和配置文件在config / autoload.php中自动加载。

这个设置在我的开发机器上运行得非常好(OS X,PHP 5.3.14)。但是,当我在我们的开发服务器(Ubuntu Precise,PHP 5.3.10)上运行项目时,它不起作用。配置参数似乎没有传递给库的问题。我收到以下错误消息:

Severity: Notice
Message:  Undefined index: dataServer
Filename: libraries/CIFX.php
Line Number: 9

Severity: Notice
Message:  Undefined index: dataPort
Filename: libraries/CIFX.php
Line Number: 9

Severity: Notice
Message:  Undefined index: dataType
Filename: libraries/CIFX.php
Line Number: 9

Severity: Notice
Message:  Undefined index: dataURLType
Filename: libraries/CIFX.php
Line Number: 9

我的库/ CIFX.php文件如下所示:     

require('FX.php');

class CIFX extends FX {

    function __construct ($params = array())
    {
        parent::__construct($params['dataServer'], $params['dataPort'], $params['dataType'], $params['dataURLType']);
    }

}
?>

我的config / CIFX.php文件如下所示:

$config['dataServer'] = '192.168.1.10';
$config['dataPort'] = '80';
$config['dataType'] = 'FMPro7';
$config['dataURLType'] = '';
$config['dbuser'] = '';
$config['dbpassword'] = '';

根据Codeigniter manual,这应该有效。

非常感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

初始化课程时需要传递参数

$params = array(
    'dataServer' =>  $this->config->item('dataServer');, 
    'dataPort'   =>  $this->config->item('dataPort');
);

$this->load->library('CIFX ', $params);
相关问题