Home >Backend Development >PHP Tutorial >thinkphp field mapping
When using thinkphp, the name in the form must be the same as the name in the database. In this way, the data can be inserted into the database. For greater security, sometimes we don’t want others to know the field names in the database. In this case, we can use thinkphp Field mapping
namespace HomeModel;
use ThinkModel;
class UserModel extends Model{
$_map(){
“ name"=>"username"; //Map the name in the form to the username in the database
<span></span>
"mail"=>"email"; //Map the mail in the form to Email<span></span>
in the database }}
//parseFieldsMap method for conversion processing. What is printed out is name and mail
$User = D('User');$data = $User->find(3);
$data = $User->parseFieldsMap($data);