CI Configuration Multi-database access method, CI database access _php Tutorial

Source: Internet
Author: User
Tags getting started with php pconnect codeigniter

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.