oop php中类之间关系的实现
我是 PHP 课程的新手。我正在编写一个与 dhcp 集成的网络 ip-mac-user 日志系统。我有用户、子网、单位。我为每个创建了类,并创建了参数和函数来填充参数以及一些关于它们的作用的 mysql 代码。但这些类之间是有关系的。我可以把这些关系的代码、功能放在哪里,比如子网和单元之间有mn个关系,我应该把关系代码放在哪里?
I am new in PHP with classes. I am coding an network ip-mac-user logging system integrated with dhcp. I have users, subnets, units. I created classes for each and created parameters and functions to fill the parameters and some mysql codes about what they do. but there are relationships among these classes. where can I put these relations' codes, functions, for example there are m-n relations between subnets and units, where should I put the relationship codes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在与另一个类相关的类中。只要确保没有循环引用,否则会遇到内存问题。
In the class that relates to the other class. Just make sure you don't have circular references or you will run into memory trouble.
你是想问如何存储关联吗?如果是这样:
http://articles.sitepoint.com/article/hierarchical-data-database< /a>
http://en.wikipedia.org/wiki/Associative_Entities
Are you asking how to store associations? If so:
http://articles.sitepoint.com/article/hierarchical-data-database
http://en.wikipedia.org/wiki/Associative_Entities