牧尾竜一
ryuic****@jom*****
2008年 7月 14日 (月) 10:03:24 JST
JOMRです。
少し複雑なのですが、
データベースなどの設定などを一つの設定ファイルにまとめたいと考えて
とりあえずホスト名だけを試そうと思い
config/database.phpに
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
$this->config->load('customer_config', TRUE);
$this->db_host = $this->config->item('db_host', 'config_customer');
$active_group = "default";
$active_record = TRUE;
$db['default']['hostname'] = $this->db_host;
:
:
?>
config/config_customer.phpに
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
$config['db_host'] = 'localhost';
?>
そしてコントローラーには
function Customer()
{
parent::Controller();
$this->load->library('session');
$this->load->helper(array('form', 'url'));
$this->load->model('Customer_model');
$this->config->load('config_customer', TRUE);
}
モデルに
<?php
class Customer_model extends Model {
function Customer_model()
{
parent::Model();
$this->load->database();
}
}
?>
と記述してみたのですがダメでした。
出来れば一箇所の変更で設定変更が出来るようにと思っているのですがかえって
ややこしくなってしまいました。
このような場合どのように対処すればいいでしょうか?