thinkphp field mapping

WBOY
Release: 2016-08-08 09:24:03
Original
1402 people have browsed it

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);

The above introduces thinkphp field mapping, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template