How to realize database connection, configuration and use of CodeIgniter
This article will explain in detail how to achieve database connection, configuration and use of CodeIgniter. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
The details are as follows:
1. Database:
Create database test;create table users (id int not null,name varchar (10), pwd varchar (10), email varchar (20)) insert into users values (1recorder shunpingjinjiao shunpingzhongjinshunpingjinjiaaqing163.com'); insert into users values (2mianshunping2jingshunping2fujingshunping2jinshunping2jinshunping2jinshunping2shunping2shunping2shunping2shunping2shunping2shunping2com')
two。 I use Postgreql.
Configure the database parameters in the\ CodeIgniter\ system\ application\ config\ database.php file:
$active_group = "default"; $db ['default'] [' hostname'] = "localhost"; $db ['default'] [' username'] = "postgres"; $db ['default'] [' password'] = "admin"; $db ['default'] [' database'] = "test"; $db ['default'] [' dbdriver'] = "postgre"; $db ['default'] [' dbprefix'] = "; $db ['default'] [' active_r'] = TRUE $db ['default'] [' pconnect'] = FALSE;$db ['default'] [' db_debug'] = TRUE;$db ['default'] [' cache_on'] = FALSE;$db ['default'] [' cachedir'] = ""; $db ['default'] [' port'] = "5432"
Test the file db1.php in the\ CodeIgniter\ system\ application\ controllers directory as follows:
Open the browser and type in the address:
Http://localhost:8888/index.php/MyController/db1
Ok, get it!
This is the end of this article on "how to achieve database connection, configuration and use of CodeIgniter". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.