CI Configuration Multi-database access method, CI database access
The example in this paper describes how CI configures multiple database access methods. Share to everyone for your reference, as follows:
1, modify the datebase.php file, will:
$db [' XXX '] [' pconnect '] = TRUE;
Modified to:
$db [' XXX '] [' pconnect '] = FALSE;
2, copy the original database link definition, such as the current
$db [' BBS '] [' hostname '] = ' Your database IP address '; $db [' BBS '] [' username '] = ' linked user name '; $db [' BBS '] [' password '] = ' database connection password '; $db [' BBS '] [ ' database '] = ' db name '; $db [' BBS '] [' dbdriver '] = ' mysql '; $db [' BBS '] [' dbprefix '] = ' cg_ '; $db [' BBS '] [' pconnect '] = false;$ db[' BBS ' [' db_debug '] = TRUE; $db [' BBS '] [' cache_on '] = FALSE; $db [' BBS '] [' cachedir '] = '; $db [' BBS '] [' char_set '] = ' UTF8 '; $db [' BBS '] [' dbcollat '] = ' utf8_general_ci '; $db [' BBS '] [' swap_pre '] = '; $db [' BBS '] [' autoinit '] = TRUE; $db [' BBS ' [' stricton '] = FALSE;
The others do not need to be modified and then load the constructor inside your controller:
function __construct () { parent::__construct (); $this->xxx= $this->load->database (' XXX ', TRUE); Note that the XXX here represents the above BBS, modified into BBS on the line}
How to use:
$query = $this->bbs->query ($sql);//As before, it is here to use $this->xxx-> XXX is your definition of bbs$rs = $query->result ();
More interested in CodeIgniter related content readers can view this site topic: "CodeIgniter Introductory Tutorial", "CI (codeigniter) Framework Advanced Tutorial", "PHP date and Time usage summary", "PHP object-oriented Programming introduction Tutorial", " PHP String Usage Summary, "Getting Started with Php+mysql database operations" and "PHP Common Database Operations Skills Summary"
It is hoped that this article is helpful to the PHP program design based on CodeIgniter framework.
Articles you may be interested in:
- A complete implementation method of database fetch data for getting started example of CI framework
- Resolution of the password user error caused by CI using tank auth Transfer Database
- Code for multiple databases in CI operations in PHP
- CodeIgniter How to connect, configure and use database
- Design defects and solutions of transaction processing for CodeIgniter framework database
- Database configuration using CodeIgniter under the Sina SAE cloud Platform
- Summary of optimization of CodeIgniter Operation database table
- CodeIgniter Database Operation Function Summary
- How to make the CodeIgniter database cache automatic Expiration processing
- CodeIgniter How to use the database class
http://www.bkjia.com/PHPjc/1117094.html www.bkjia.com true http://www.bkjia.com/PHPjc/1117094.html techarticle CI configuration Multi-database access method, CI database Access This article describes the CI configuration method of multi-database access. Share to everyone for your reference, as follows: 1, modify Dateba ...