Forked from yuigoto/CodeIgniter_PDOSQLiteMySQL.php
Created
November 20, 2017 18:20
-
-
Save rogeriopradoj/c54c3731ee8684f07b8436617f53270a 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 hidden or 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