How does PostgreSQL configure the database information of a model separately?

Source: Internet
Author: User
: This article mainly introduces how PHP configures the database information of a model separately. if you are interested in the PHP Tutorial, refer to it. 131 how does thinkphp link a model in the project to another database?

Requirement: a sub-project needs to call the public header (model) of another project. the header is different from the storage database of the sub-project. If this parameter is not set, the table corresponding to the header will be searched in the database configured for the sub-project, which obviously does not exist. Solution
  • Write db information to the model class constructor in the header
Function_initialize () {// Set the database link $ this-> connection = C ("SYS_CONFIG"); // Set the prefix $ this-> setProperty ("tablePrefix", SYS_DB_PREFIX ); // execute the parent class constructor parent: _ initialize ();}
  • Write specific configuration in the configuration file
'SYS_CONFIG' => array(        'db_type'   => SYS_DB_TYPE,        'db_host'   => SYS_DB_HOST,        'db_name'  => SYS_DB_NAME,        'db_user'   => SYS_DB_USER,        'db_pwd'    => SYS_DB_PWD,        'db_prefix'  => SYS_DB_PREFIX,        'db_port'   => SYS_DB_PORT,        'wkhtmltopdf_path'  => SYS_WKHTMLTOPDF_PATH,),

'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
  • '). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script

    The above introduces how to configure the database information of a model separately in php 131, including some content, and hope to help those who are interested in the PHP Tutorial.

    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.