Model: {code...} Controller: {code...} the name of the Controller database, ybdbchfjhfjjds, is changed. it should be an error, but it succeeded! Data can be searched normally. Therefore, the database is not overwritten and the database is still the model Database. in the following example, I wrote a q... model prefix:
Class classoneModel extends Model {protected $ trueTableName = ''; // prefix + table name; protected $ dbName = 'ybdbcjd '; // database name, or from the configuration file, or D () parameter settings ;}
Controller:
public function select_(){ $use=D('classone','','mysql://root16656:@localhost/ybdbchfjhfjjds'); $db=$use->select(); echo '';print_r($db);echo '
';}public function select_(){ $use=D('classone','qqqqqqqqqqqqqqqqqqqqqq','mysql://root16656:@localhost/ybdbchfjhfjjds'); $db=$use->select(); echo '';print_r($db);echo '
';}
The Controller database name is ybdbchfjhfjjds. I changed it randomly. it should be an error, but it succeeded! Data can be searched normally. Therefore, the database is not overwritten and is still a model database,
In the following example, I wrote a qqqqqqqqqqqqqqqqq prefix, and I couldn't find the data,
When will it be overwritten or not?
Reply content:
Model:
Class classoneModel extends Model {protected $ trueTableName = ''; // prefix + table name; protected $ dbName = 'ybdbcjd '; // database name, or from the configuration file, or D () parameter settings ;}
Controller:
public function select_(){ $use=D('classone','','mysql://root16656:@localhost/ybdbchfjhfjjds'); $db=$use->select(); echo '';print_r($db);echo '
';}public function select_(){ $use=D('classone','qqqqqqqqqqqqqqqqqqqqqq','mysql://root16656:@localhost/ybdbchfjhfjjds'); $db=$use->select(); echo '';print_r($db);echo '
';}
The Controller database name is ybdbchfjhfjjds. I changed it randomly. it should be an error, but it succeeded! Data can be searched normally. Therefore, the database is not overwritten and is still a model database,
In the following example, I wrote a qqqqqqqqqqqqqqqqq prefix, and I couldn't find the data,
When will it be overwritten or not?
Because D function has only two parameters. The first parameter is the resource address, and the second parameter is the model layer name.
If you place the mysql connection on the third null parameter, it will not take effect.
The mysql link parameter is the third parameter in the M function ..
So there is no overwrite.