<code>class ★Model extends Model { protected $tableName = 'abc'; }</code>
What is the use of the $tableName attribute?
Isn’t the ★ part the table name?
Why create another protected $tableName = '◆';
If ◆ is the same as ★, then it will be repeated. Yes, I did it many times,
If it is different, then when $mydb = D("★") is created, the file will not be found?
<code>class ★Model extends Model { protected $tableName = 'abc'; }</code>
What is the use of the $tableName attribute?
Isn’t the ★ part the table name?
Why create another protected $tableName = '◆';
If ◆ is the same as ★, don’t repeat it Yes, I did it many times,
If it is different, then when $mydb = D("★") is created, the file will not be found?
The name of the model can be different from the name of the data table, which is more flexible. For example, the data table is pre_q_a, and the model name can be QaModel, protected $tableName = 'q_a'
This is due to the naming problem of PHP and SQL databases:
PHP classes are named using camel case, such as UserGroup; methods are named using camel case, such as public function getUserInfo(){}; PHP functions are named using lowercase letters and The format of underscores, such as function get_string_length(){};
MySQL database tables and fields basically use lowercase letters and underscores, such as table name user_group, field name create_time.