model:
<code>class classoneModel extends Model { protected $trueTableName = ''; //前缀+表名; protected $dbName = 'ybdbcjd'; //库名,也可以从配置文件,或者 D() 参数设置; } </code>
Controller:
<code>public function select_() { $use=D('classone','','mysql://root16656:@localhost/ybdbchfjhfjjds'); $db=$use->select(); echo '<pre class="brush:php;toolbar:false">';print_r($db);echo ''; } public function select_() { $use=D('classone','qqqqqqqqqqqqqqqqqqqqqq','mysql://root16656:@localhost/ybdbchfjhfjjds'); $db=$use->select(); echo '
';print_r($db);echo ''; }
The library name of Controller is ybdbchfjhfjjds. I changed it randomly. Logically speaking, there should be an error, but it actually succeeded! The data can be searched normally, so the library has not been overwritten and it is still the model library.
In the following example, I wrote the prefix qqqqqqqqqqqqqq, but the data cannot be found,
When will this be covered and when will it not be covered?
model:
<code>class classoneModel extends Model { protected $trueTableName = ''; //前缀+表名; protected $dbName = 'ybdbcjd'; //库名,也可以从配置文件,或者 D() 参数设置; } </code>
Controller:
<code>public function select_() { $use=D('classone','','mysql://root16656:@localhost/ybdbchfjhfjjds'); $db=$use->select(); echo '<pre class="brush:php;toolbar:false">';print_r($db);echo ''; } public function select_() { $use=D('classone','qqqqqqqqqqqqqqqqqqqqqq','mysql://root16656:@localhost/ybdbchfjhfjjds'); $db=$use->select(); echo '
';print_r($db);echo ''; }
The library name of Controller is ybdbchfjhfjjds. I changed it randomly. Logically speaking, there should be an error, but it actually succeeded! The data can be searched normally, so the library has not been overwritten and it is still the model library.
In the following example, I wrote the prefix qqqqqqqqqqqqqq, but the data cannot be found,
When will this be covered and when will it not be covered?
Because the D function only has two parameters, the first parameter is the resource address, and the second is the model layer name
If you put the mysql connection in the third empty parameter, of course it will not take effect
The mysql link parameter is the third parameter in the M function. .
So there is no coverage or no coverage