user6159419
user6159419

Reputation: 247

How to set database file path in htaccess in CodeIgniter?

I have Firebird database file Twenty.FDB. Previously it was located in C:\db folder and I was using path as 'database' => 'C:\db\Twenty.FDB' and it was working fine.

Now I want to upload my codeigniter webservices on server and want to set its path as /db/Twenty.FDB. Following are changes that I have done but it is not working for me. My question is can I use relative path or have I only choice to use absolute path.

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => 'sysdba',
    'password' => 'masterkey',
    'database' => '/db/Twenty.FDB',
    'dbdriver' => 'ibase',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'NONE',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

Upvotes: 0

Views: 435

Answers (1)

Brian Gottier
Brian Gottier

Reputation: 4582

Use FCPATH, because without FCPATH CodeIgniter thinks you are trying to reference a db directory off of root.

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => 'sysdba',
    'password' => 'masterkey',
    'database' => FCPATH . 'db/Twenty.FDB',
    'dbdriver' => 'ibase',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'NONE',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

Upvotes: 2

Related Questions