Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

问下EvaEngine有分表的功能吗? #10

Closed
PoplarDddCN opened this issue Jan 15, 2016 · 3 comments
Closed

问下EvaEngine有分表的功能吗? #10

PoplarDddCN opened this issue Jan 15, 2016 · 3 comments

Comments

@PoplarDddCN
Copy link

问下EvaEngine有分表的功能吗?比如根据ID范围来分表:

function getTable( $uid ){
  $ext =  substr ( md5($uid) ,0 ,2 );
  return "user_".$ext;
}

EvaEngine有这种功能吗?

@AlloVince
Copy link
Member

可以自己实现一个BaseModel继承Eva\EvaEngine\Mvc\Model然后覆盖getSource方法

@PoplarDddCN
Copy link
Author

AlloVince类似下面这样吗?

class Users extends Eva\EvaEngine\Mvc\Model {
    public function getSource () {
       $ext =  substr(md5($uid), 0, 2);//通过UID来拼接用户表
       $this->setSource('users_' . $ext);
    }
}

问题没搞清楚 uid 是在什么时候传到 getSource() 方法里?还请劳驾讲一下,先谢谢啦!

@AlloVince
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants