{"action":"opened","issue":{"url":"https://api.github.com/repos/top-think/think/issues/288","repository_url":"https://api.github.com/repos/top-think/think","labels_url":"https://api.github.com/repos/top-think/think/issues/288/labels{/name}","comments_url":"https://api.github.com/repos/top-think/think/issues/288/comments","events_url":"https://api.github.com/repos/top-think/think/issues/288/events","html_url":"https://github.com/top-think/think/issues/288","id":132865894,"number":288,"title":"一个改进想法,但是不知道是否应该合并","user":{"login":"zizhilong","id":7838661,"avatar_url":"https://avatars.githubusercontent.com/u/7838661?v=3","gravatar_id":"","url":"https://api.github.com/users/zizhilong","html_url":"https://github.com/zizhilong","followers_url":"https://api.github.com/users/zizhilong/followers","following_url":"https://api.github.com/users/zizhilong/following{/other_user}","gists_url":"https://api.github.com/users/zizhilong/gists{/gist_id}","starred_url":"https://api.github.com/users/zizhilong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zizhilong/subscriptions","organizations_url":"https://api.github.com/users/zizhilong/orgs","repos_url":"https://api.github.com/users/zizhilong/repos","events_url":"https://api.github.com/users/zizhilong/events{/privacy}","received_events_url":"https://api.github.com/users/zizhilong/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-02-11T01:15:57Z","updated_at":"2016-02-11T01:15:57Z","closed_at":null,"body":"我这里的团队在使用THINKPHP时,遇到过要在单次执行中插入或者修改大量的数据\r\n即便使用addAll,也不太适合.当时的思路是写了3个扩展方法,\r\n插入\r\n$m=M('要插入数据的表');\r\nforeach($datas as $data)\r\n{\r\n       $m->bAdd($data);\r\n}\r\n$m->bUpdate();\r\n更新\r\n$m=M('要插入数据的表');\r\nforeach($datas as $data)\r\n{\r\n       $m->bSave(array('id'=>$data['id\r\n[Uploading Model.class.zip…]()\r\n'],'更新的字段'=>$data['val']);\r\n}\r\n$m->bUpdate();\r\n\r\nb指的是bulk\r\n在逻辑内部,插入和修改请求会被缓存起来,当积累到一定程度,执行一次insert或update \r\n更新使用的是case when\r\n做一次性百万条数据插入这个是我能找到最快的办法.\r\n\r\nso 我想说的意思是,这种需求是否适合作为一个model的traits如果适合我可以写写看"}}