您好,欢迎访问一九零五行业门户网

ThinkPHP(百万级)数据分表技术的例子

为大家说说thinkphp内置的分表算法处理百万级数据的例子,有需要的朋友,可以看看。从thinkphp中抽取出来的代码,看看人家是如何实现大数据分表的。
数据表:house_member_0house_member_1house_member_2house_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(); }}
其它类似信息

推荐信息