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

使用模型和模型关系的好处 #1

Open
clms2 opened this issue May 10, 2018 · 0 comments
Open

使用模型和模型关系的好处 #1

clms2 opened this issue May 10, 2018 · 0 comments

Comments

@clms2
Copy link
Owner

clms2 commented May 10, 2018

https://segmentfault.com/q/1010000014056473/a-1020000014069076
补充点,模型关系底层的sql语句是单独去查的,比如$order->user->user_name,会执行两条sql,一条查order数据,一条根据order数据返回的user_id去查user表数据。意味着如果分库了只需在模型里加个对应的connection指定下即可,而用join形式就比较麻烦,需要改对应的join代码, 而且也不支持跨库join,用关系的话可以跨库获取数据。

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

1 participant