In-depth analysis of addall methods in thinkphp

Source: Internet
Author: User
Tags addall

reason :

In the middle of the control system encountered a user batch allocation of roles, just beginning to think of is the loop insert, but immediately to the negative, the recycling database developers of the big bogey ah, so find the manual to find data write see Bulk operation: AddAll (), test success, thought everything is all right, But when the second operation is prompted to fail, to find the reason, originally the database already exists in the data AddAll () No overwrite caused the error

Workaround :

Find thinkphp source turned to library/think/model.class.php found AddAll method: Public Function AddAll ($dataList, $options =array (), $ Replace=false) So the second understand, replace must be asked if you overwrite the existing data, so modify my AddAll method is: $user->addall ($data, Array (), true): Test the problem again.

This article is from the "Love Xiao" blog, please be sure to keep this source http://aixiao.blog.51cto.com/7244439/1410495

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.