Home > Article > Backend Development > Examples of ThinkPHP (million-level) data table technology
Let me tell you about an example of ThinkPHP's built-in sub-table algorithm for processing millions of data. Friends in need can take a look.
Extract the code from thinkphp to see how others implement big data table splitting. Data sheet: house_member_0 house_member_1 house_member_2 house_member_3 model: class MemberModel extends AdvModel { protected $partition = array('field'=>'username','type'=>'id','num'=>'4'); public function getDao($data=array()) { $data = empty($data) ? $_POST : $data; $table = $this->getPartitionTableName($data); return $this->table($table); } } action: class MemberAction extends BaseAction { public function login() { if($this->isPost()) { $this->validToken(); $dao = D('Member')->getDao(); $res = $dao->where('username = '.$_POST['username'])->find(); // output 为自定义方法 // $isAjax - bool $this->output(false); } $this->display(); } } |