I know there are two ways to define table prefixes when creating M-models,
One is in $tablePrefix one is defined in the $connection,
Why do I use it here?
protected $connection = array ( 'DB_TYPE' => 'mysql', //数据库类型 'DB_USER' => 'root', //用户名 'DB_PWD' => '', //密码 'DB_HOST' => 'localhost', //域名 'DB_PORT' => '3306', //?? 'DB_NAME' => 'minute1', //库名 'DB_CHARSET' => 'UTF8', //编码 'DB_PREFIX' => 'minute1_' //★★★★★★★★★★★★数据库表前缀minute1_ );
No, but the use of protected $tablePrefix = "Minute1_" is good, please tell me when to use which kind of?
Reply content:
I know there are two ways to define table prefixes when creating M-models,
One is in $tablePrefix one is defined in the $connection,
Why do I use it here?
protected $connection = array ( 'DB_TYPE' => 'mysql', //数据库类型 'DB_USER' => 'root', //用户名 'DB_PWD' => '', //密码 'DB_HOST' => 'localhost', //域名 'DB_PORT' => '3306', //?? 'DB_NAME' => 'minute1', //库名 'DB_CHARSET' => 'UTF8', //编码 'DB_PREFIX' => 'minute1_' //★★★★★★★★★★★★数据库表前缀minute1_ );
No, but the use of protected $tablePrefix = "Minute1_" is good, please tell me when to use which kind of?
$tablePrefix is defined in the model, the priority is greater than the configuration file, the use of the case is generally your project in the initial table prefix all such as "A_", you defined in the configuration file
'DB_PREFIX'=>'a_'
But after adding a b_temp table, this time to instantiate the temp if not processed, the system will look for a_temp, this table does not exist, this time need to define in the temp model $tableprefix= ' b_ ';