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
);
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
);
Related
I am hosting a CodeIgniter API on GCP App Engine and I cant connect to the GCP Cloud SQL. I create the instance and database, but when I try to conect via CI I got a timeout message
error screen
My databse config on CI is:
$db['default'] = array(
'dsn' => 'mysql:unix_socket=/instance_name/instancia;dbname=project_name',
'hostname' => 'http://00.000.00.00',//here i put the public ip from the sql instance
'username' => 'user',
'password' => 'passwd',
'database' => 'projeto',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => yes,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
I've been banging my head on this for a while, myself, and finally cracked it! Here's what my db config looks like:
$db['default'] = array(
'dsn' => '',
'hostname' => '/cloudsql/PROJECT-NAME:REGION:DATABASE',
'username' => 'USERNAME',
'password' => 'PASSWORD',
'database' => 'DATABASE_NAME',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
// 'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
The important bits are that the dsn is empty and the hostname is the full path to the unix socket. The rest of it should be about the same.
Hope that helps you, too!
I Developed Codeigniter app with SQL server connection. it is properly connected when using PHP 5.6 on windows 7 PC, but same application not working on windows 10 with same PHP version. showing the error
$db['default'] = array(
'dsn' => '',
'hostname' => '192.168.0.241',
'username' => 'sa',
'password' => 'mypw',
'database' => 'dbsrver',
'dbdriver' => 'sqlsrv',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
You might have some error in configuration. Make sure you have correctly configure database.
In application/config/databse.php
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'write password if any otherwise leave it empty',
'database' => 'Your_Database_Name',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
I always get the following error in my codeigniter 3 application when I start using a sqlite3 database.
SQLite3::query(): Unable to prepare statement: 1, no such table: pages
I have read somewhere that this is the case when you have the wrong path to the databse. My database is located in application/db/pages.sqlite
This is the config for the sqlite database:
$db['pages'] = array(
'dsn' => '',
'hostname' => '',
'username' => '',
'password' => '',
'database' => APPPATH.'db/pages.sqlite',
'dbdriver' => 'sqlite3',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
What have I done wrong?
Try this, it worked for me before
'database' => 'sqlite:'.APPPATH.'db/pages.sqlite',
Also make sure that folder db is readable by your app.
First you need to check that sqlite3 php module is installed on your web server or not?
This will required to work Codeigniter3 sqlite3 db driver.
If its not working then provide 'dsn' string. This will definitely working.
First thing try to check your php.ini and uncomment this
extension=php_pdo_sqlite.dll
extension=php_sqlite3.dll
and try this
$db['default'] = array(
'dsn' => 'sqlite:application/db/pages.sqlite',
'hostname' => 'localhost',
'username' => '',
'password' => '',
'database' => '',
'dbdriver' => 'pdo',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
Hi all this is my first question, and it might be that Im currently over confusing matters.... I have got a database config file which specifies the SQL database that is used. What I want to do is make it so that the database name is the same as the subdomain. Thus meaning that the same php can be used to access different databases. If you get me. Any help greatly appreciated.
$db['default'] = array(
'dsn' => '',
'hostname' => 'databaseserver',
'username' => 'admin',
'password' => 'password',
'database' => 'subdomain',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
I want connect to 3 databases. I don't have any problem if i connect just two databases. When i try to connect 3 databases. i have problem like i cant connect to database two.
this my config at database.php :
$db['default'] = array(
'dsn' => '',
'hostname' => '192.168.11.29,1433',
'username' => 'userhsp',
'password' => 'hsp432#',
'database' => 'HSP',
'dbdriver' => 'mssql',
'dbprefix' => '',
'pconnect' => TRUE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => FALSE,
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['crm'] = array(
'dsn' => '',
'hostname' => '192.168.11.29,1433',
'username' => 'userhsp',
'password' => 'hsp432#',
'database' => 'CRM',
'dbdriver' => 'mssql',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => FALSE,
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['pltapol'] = array(
'dsn' => '',
'hostname' => '192.168.11.29,1433',
'username' => 'userhsp',
'password' => 'hsp432#',
'database' => 'pltapol',
'dbdriver' => 'mssql',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => FALSE,
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
and in my model like this :
private $db2;
private $db3;
public function __construct()
{
parent::__construct();
$this->db2 = $this->load->database('crm', TRUE);
$this->db3 = $this->load->database('pltapol', TRUE);
}
i just can get object from database pltapol, but i dont get object from crm. how to fix it?
I want to answer my question. i tried to use
$this->db2->db_select() or $this->db3->db_select()
if i want to use that connection before $this->db2->query() or before $this->db2->query()
that is work!
happy coding :)