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.