Using sqlite3 database in Codeigniter_PHP tutorial

WBOY
Release: 2016-07-21 14:58:29
Original
898 people have browsed it

It is easy to use mysql database in Codeigniter. Just configure the database name, account and password in <font face="NSimsun">application/config/database.php</font> and you can use it.

It is a little more troublesome to switch to sqlite. Codeigniter uses PHP5's own driver to support sqlite by default, and this driver only supports sqlite 2.x version. Fortunately, starting from Codeigniter 2.1, the pdo driver of sqlite has been built-in. Support for sqlite3 can be achieved through the pdo driver.

Edit options in <font face="NSimsun">application/config/database.php</font>:

$db['default']['hostname'] = 'sqlite:' . FCPATH . '../db/tms.db';
$db['default']['username'] = '';
$db['default']['password'] = '';
$db['default']['database'] = '';
$db['default']['dbdriver'] = 'pdo';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
Copy after login

This way you can directly access the sqlite database.

Source of this article: Mango Station

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/363808.htmlTechArticleUsing the mysql database in Codeigniter is a breeze, as long as the database name is configured in application/config/database.php , account password can be used. Replace it with sqlite...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template