Php Framework-when does the table PREFIX of the thinkPHPM model use $ tablePrefix and 'DB _ prefix '?

Source: Internet
Author: User
I know that when creating the M model, there are two ways to define the table prefix, one is in $ tablePrefix and the other is defined in $ connection, why do I use {code...} here ...} no. you can use protected $ tablePrefix & quot; minute1 _ & quot;. When should I use it? I know there are two ways to define the table prefix when creating the M model,
One is in $ tablePrefix and the other is defined in $ connection,

Why am I using

Protected $ connection = array ('Db _ type' => 'mysql', // Database TYPE 'DB _ user' => 'root ', // username 'DB _ pwd' => '', // password 'DB _ host' => 'localhost ', // domain name 'DB _ port' => '123 ',//?? 'Db _ name' => 'minute1', // database NAME 'DB _ charset' => 'utf8 ', // Encode 'DB _ prefix' => 'minute1 _'//★★★★★★★★★★★★Database table prefix minute1 _);

No. you can use protected $ tablePrefix = "minute1 _". When should I use it?

Reply content:

I know there are two ways to define the table prefix when creating the M model,
One is in $ tablePrefix and the other is defined in $ connection,

Why am I using

Protected $ connection = array ('Db _ type' => 'mysql', // Database TYPE 'DB _ user' => 'root ', // username 'DB _ pwd' => '', // password 'DB _ host' => 'localhost ', // domain name 'DB _ port' => '123 ',//?? 'Db _ name' => 'minute1', // database NAME 'DB _ charset' => 'utf8 ', // Encode 'DB _ prefix' => 'minute1 _'//★★★★★★★★★★★★Database table prefix minute1 _);

No. you can use protected $ tablePrefix = "minute1 _". When should I use it?

$ TablePrefix is defined in the Model. the priority is greater than that in the configuration file. Generally, the prefix of all tables in the initial stage of your project is "_", you defined in the configuration file

'DB_PREFIX'=>'a_'

ButB _tempTable. If no processing is performed when the temp instance is instantiated, the system will queryA_tempThe table does not exist. in this case, you need to define $ tablePrefix = 'B _' in the Temp model.

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.