thinkphp Field Mapping issues

Source: Internet
Author: User
Class Projectaction extends action{
Protected $_map = Array (
' username ' + ' user ',//map username in the form? User field of data table
' Password ' + ' pwd ',//map the password in the form? The PWD field of the data table
);

Public Function Insert () {
$Project = D (' Project ');
if ($Project->create ()) {
echo "Create data object successfully!" ";
if ($Project->add ()) {
Echo ' Add data success ';
}else {
Echo ' Add data failed ';
}
}else{
Echo ' failed to create data object ';
}

}

}

Insert the form data into the table, the execution of the Insert function, the data object creation failed, ask you what is the problem?


Reply to discussion (solution)

Paste the contents of the Model project file

Paste the contents of the Model project file

Model project is not defined

Paste the contents of the Model project file



I wrote the next data can be inserted
Attached to the official manual can be seen in the manual http://doc.thinkphp.cn/manual/create.html





Above is the form code
The fields of the data table are ID, user, PWD, respectively.

Protected $_map = Array (
' username ' + ' user ',//map username in the form? User field of data table
' Password ' + ' pwd ',//map the password in the form? The PWD field of the data table
);

Put it in the Projectmodel.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.