-
-
Save antelove19/846bb2c084beb8fa50d04080194889de to your computer and use it in GitHub Desktop.
How to setup PDO and SQLite for CodeIgniter (for SQLite and MySQL). This is the `database.php` file in `the application/config` folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
$active_group = 'default'; | |
$query_builder = TRUE; | |
// FOR SQLITE | |
$db['default'] = array( | |
'dsn' => 'sqlite:[path-to-database-file]', | |
'hostname' => 'localhost', | |
'username' => '', | |
'password' => '', | |
'database' => '', | |
'dbdriver' => 'pdo', | |
'dbprefix' => '', | |
'pconnect' => TRUE, | |
'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 | |
); | |
// FOR MYSQL | |
$db['default'] = array( | |
'dsn' => 'mysql:host=[host-address];dbname=[db-name]', | |
'hostname' => '[host-address]', | |
'username' => '[db-username]', | |
'password' => '[db-password]', | |
'database' => '[db-name]', | |
'dbdriver' => 'pdo', | |
'dbprefix' => '', | |
'pconnect' => TRUE, | |
'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 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment