Home > Backend Development > PHP Tutorial > Examples of ThinkPHP (million-level) data table technology

Examples of ThinkPHP (million-level) data table technology

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-25 08:59:46
Original
1752 people have browsed it
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);
    }
}
Copy after login

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();
    }
}
Copy after login


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