How to connect CodeIgniter to sqlite3 database like a PRO
CodeIgniter comes with ready-to-use libraries for almost all standard databases, once you connect your database, you can use standard MySQL queries and query builders so you don’t need to modify your code at all.
Steps to connect CodeIgniter to sqlite3 database
- Go to your CodeIgniter directory / application and create a new folder named “db”.
- Copy your sqlite3 database file inside this newly created folder.
- Go to your CodeIgniter directory / application / config /database.php and modify $db[‘default’] so that it looks exactly like this (you can copy this code and replace there):
$db['default'] = array(
'dsn' => '',
'hostname' => '',
'username' => '',
'password' => '',
'database' => './application/db/database.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
);
as you can see, your database location is indicated as
'database' => './application/db/database.sqlite'
If you need to modify database location or its name, make sure you set the correct location and name here as well.
Want free cloud hosting?
Go to this link and register to get $100 in cloud credits from DigitalOcean today and deploy your app in seconds. DigitalOcean is one of the best cloud services providers in the world today, check this medium article to know more.
There’s more:
$100 Free Money from FBS : regulated by IFSC, this broker is one of the oldest and most established out there, operating since 2009.
Requirements:
- Register a new account with $100 on it
- Use the leverage of 1:500 to maximize your profits
- Earn up to $100 withdrawable profits in 30 days
Available Markets: Cryptocurrencies, Stocks, CFDs, Metals, Commodities, Foreign Exchange
$30 Free Money from Tickmill : regulated by FSA, this broker operates since 2015.
Requirements:
- Register a new account with $30 on it
- Use the leverage of up to 1:500 to maximize your profits
- Withdraw the profits after 5 lots are traded
- The maximum withdrawal amount is $300
Available Markets: Stock Indices, Oil, Precious Metals, Bonds, Foreign Exchange.
$30 Free Money from Roboforex : regulated by CySEC and IFSC, Roboforex is operating since 2009 and is one of the most popular brokers among traders today.
Requirements:
- Open an account and deposit $10 in order to verify your payment method (can be withdrawn at any time) and get $30 as a gift
- Profits are withdrawable without limitations
- If you trade the necessary number of lots, you can withdraw the $30 too
Available Markets: Stocks (all NYSE, NASDAQ, and AMEX shares + German and Chinese listed companies), Stock CFDs (on all stocks, $1.5 per trade fee on US listed shares), Indices, ETFs, Commodities, Metals, Energy Commodities, Cryptocurrencies, Cryptoindices, Foreign Exchange.
Thank you for reading. If you enjoyed this article, feel free to hit that clap button to help others find it.