user6159419 user6159419 - 1 year ago 85
PHP Question

Codeigniter: How to set database file path in htaccess

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.

So please help me in this regard.

$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
);

Answer Source

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
);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download